Polygon spawn problem

About advanced scenes, and the Thyme scripting language used in Algodoo.

Polygon spawn problem

Postby Kilinich » Mon Mar 14, 2011 9:19 pm

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 :idea: ).

http://en.wikipedia.org/wiki/Center_of_mass
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Polygon spawn problem

Postby Someone Else » Thu Mar 17, 2011 3:18 am

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?
Matthias Wandel is epic, in my humble opinion.
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.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 4 guests