How to calculate Mass of a Polygon?

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

How to calculate Mass of a Polygon?

Postby Xray » Mon Jan 16, 2017 9:13 am

I know that the Mass of a box or circle can be calculated with area * density, but that doesn't seem to work with polygons. So, does anyone know how I could calculate the mass of a polygon? OR is the Mass directly readable some how?
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: How to calculate Mass of a Polygon?

Postby carl00s01 » Thu Jan 19, 2017 2:34 am

But that is area*density even with polygons...I tested here and it works.
User avatar
carl00s01
 
Posts: 24
Joined: Fri Nov 26, 2010 7:03 pm
Location: Brazil

Re: How to calculate Mass of a Polygon?

Postby Xray » Thu Jan 19, 2017 3:26 am

Thanks for your reply, carl00s01, but it does not work for my gold ring polygons in my recent scene http://www.algodoo.com/algobox/details.php?id=150626. If you load my scene and zoom in so that you can select just one gold ring, you will see that they all have a mass of exactly 100 grams (except for thief number 8, who has been stealing one gram per gold ring). Now, if you multiply the density of one gold ring by it's area, the result is approximately 9.8 grams (not 100 grams)! So, maybe area times density works for a closed polygon, but not for one with holes in it like my gold rings!

The way that I calculate it in my scene is, I reverse-calculated one ring, and found that I could divide the density by a particular constant (you can see my calculation in the onSpawn event). But I was hoping that it could be calculated without fudging it.
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: How to calculate Mass of a Polygon?

Postby carl00s01 » Fri Jan 20, 2017 8:06 am

I saw your scene and it indeed gives the wrong mass. I tried to recreate that ring with all those codes and it gave me the right mass when I printed it in a scene.my variable. I don't know what you've done to make this bug appear, but it mass for any geometry is area*density...
User avatar
carl00s01
 
Posts: 24
Joined: Fri Nov 26, 2010 7:03 pm
Location: Brazil

Re: How to calculate Mass of a Polygon?

Postby Xray » Fri Jan 20, 2017 5:45 pm

Hmmmmm..... very strange. I wish I knew what I did too! :lol:

Thanks again,

Xray
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: How to calculate Mass of a Polygon?

Postby Kilinich » Mon Jan 23, 2017 5:13 pm

I can't reproduce bug with area calculation... I have correct area for polygons. :wtf:
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: How to calculate Mass of a Polygon?

Postby Xray » Mon Jan 23, 2017 6:02 pm

I noticed that all of the gold rings in my scene have the wrong area value. If I select a gold ring and then resize it and put it back to the original size, then the area is correct! So, I assume that the problem originally occurred when I copy and pasted those gold rings. Something that I did caused the incorrect area calculation, which was off by a factor of 10!

I won't worry about it any longer. Thanks for your help!
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 3 guests

cron