Polygon spawn problem
2 posts • Page 1 of 1
Polygon spawn problem
Recently, I faced with a problem that I can't spawn many-nodes polygon in correct position. It's because pos := [x,y] means position of mass center, not origin of vecs/surfaces points. So I need to calculate coordinates of mass center (in surfaces coordinates) and shift pos according it.
For triangle it's simple: [(x1+x2+x3) /3,( y1+y2+y3)/3] but for other polygons you need to use pretty complex formulas (but you always can split it in triangles, right
).
http://en.wikipedia.org/wiki/Center_of_mass
For triangle it's simple: [(x1+x2+x3) /3,( y1+y2+y3)/3] but for other polygons you need to use pretty complex formulas (but you always can split it in triangles, right
http://en.wikipedia.org/wiki/Center_of_mass
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Polygon spawn problem
Do you always need to know where the center of mass is? I can think of one situation where you want to spawn the polygon at the center of mass, irrelevant of the surfaces. (when you know where you want the center of mass to be, but don't know what the surfaces are and the polygon is symmetrical)
Or maybe you could create a universal scene.my.math function for this problem.
AND WHAT HAVE YOU DONE TO YOUR AVATAR?!?!?
Where's the bunny?
Or maybe you could create a universal scene.my.math function for this problem.
AND WHAT HAVE YOU DONE TO YOUR AVATAR?!?!?
Where's the bunny?
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
2 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests



