discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Centre of Mass

AP
Andrew Plumb
Tue, Nov 24, 2015 12:51 AM

On second thoughts, a better place to calculate and report the 3D volume(s) and centroid(s) or 2D area(s), centroids and perimeter length(s) would be here:

https://github.com/openscad/openscad/blob/master/src/mainwin.cc#L1917-L1944 https://github.com/openscad/openscad/blob/master/src/mainwin.cc#L1917-L1944

…where the Render (F6) summary report is generated.

Andrew.

On Nov 23, 2015, at 9:57 AM, clothbot andrew@plumb.org wrote:

Total volume and center-of-mass could be calculated at export time, right
around here:

https://github.com/openscad/openscad/blob/master/src/export.cc#L142-L187

Nice little overview of the math involved for volume here:

http://n-e-r-v-o-u-s.com/blog/?p=4415

...and for center of mass, aka "Centroid of a 3D shell described by 3 vertex
facets":

http://paulbourke.net/geometry/polygonmesh/

...or...

http://wwwf.imperial.ac.uk/~rn/centroid.pdf

It's a bit more involved, but same underlying principles.

Andrew.

--
View this message in context: http://forum.openscad.org/Centre-of-Mass-tp14707p14714.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--

"The future is already here.  It's just not very evenly distributed" -- William Gibson

Me: http://clothbot.com/wiki/ http://clothbot.com/wiki/

On second thoughts, a better place to calculate and report the 3D volume(s) and centroid(s) or 2D area(s), centroids and perimeter length(s) would be here: https://github.com/openscad/openscad/blob/master/src/mainwin.cc#L1917-L1944 <https://github.com/openscad/openscad/blob/master/src/mainwin.cc#L1917-L1944> …where the Render (F6) summary report is generated. Andrew. > On Nov 23, 2015, at 9:57 AM, clothbot <andrew@plumb.org> wrote: > > Total volume and center-of-mass could be calculated at export time, right > around here: > > https://github.com/openscad/openscad/blob/master/src/export.cc#L142-L187 > > Nice little overview of the math involved for volume here: > > http://n-e-r-v-o-u-s.com/blog/?p=4415 > > ...and for center of mass, aka "Centroid of a 3D shell described by 3 vertex > facets": > > http://paulbourke.net/geometry/polygonmesh/ > > ...or... > > http://wwwf.imperial.ac.uk/~rn/centroid.pdf > > It's a bit more involved, but same underlying principles. > > Andrew. > > > > -- > View this message in context: http://forum.openscad.org/Centre-of-Mass-tp14707p14714.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org -- "The future is already here. It's just not very evenly distributed" -- William Gibson Me: http://clothbot.com/wiki/ <http://clothbot.com/wiki/>
NH
nop head
Tue, Nov 24, 2015 10:04 AM

Even if it was reported it doesn't solve the original problem of adjusting
the model to have the com in a specified place unless you use trial and
error. Even if the com was available numerically in OpenSCAD it doesn't
solve the original problem. You need to write an equation for the com
dependent on the variable of the geometry you wish to change and then solve
it to create the geometry.
On Nov 24, 2015 12:52 AM, "Andrew Plumb" andrew@plumb.org wrote:

On second thoughts, a better place to calculate and report the 3D
volume(s) and centroid(s) or 2D area(s), centroids and perimeter length(s)
would be here:

https://github.com/openscad/openscad/blob/master/src/mainwin.cc#L1917-L1944

…where the Render (F6) summary report is generated.

Andrew.

On Nov 23, 2015, at 9:57 AM, clothbot andrew@plumb.org wrote:

Total volume and center-of-mass could be calculated at export time, right
around here:

https://github.com/openscad/openscad/blob/master/src/export.cc#L142-L187

Nice little overview of the math involved for volume here:

http://n-e-r-v-o-u-s.com/blog/?p=4415

...and for center of mass, aka "Centroid of a 3D shell described by 3
vertex
facets":

http://paulbourke.net/geometry/polygonmesh/

...or...

http://wwwf.imperial.ac.uk/~rn/centroid.pdf

It's a bit more involved, but same underlying principles.

Andrew.

--
View this message in context:
http://forum.openscad.org/Centre-of-Mass-tp14707p14714.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--

"The future is already here.  It's just not very evenly distributed" --
William Gibson

Me: http://clothbot.com/wiki/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Even if it was reported it doesn't solve the original problem of adjusting the model to have the com in a specified place unless you use trial and error. Even if the com was available numerically in OpenSCAD it doesn't solve the original problem. You need to write an equation for the com dependent on the variable of the geometry you wish to change and then solve it to create the geometry. On Nov 24, 2015 12:52 AM, "Andrew Plumb" <andrew@plumb.org> wrote: > On second thoughts, a better place to calculate and report the 3D > volume(s) and centroid(s) or 2D area(s), centroids and perimeter length(s) > would be here: > > https://github.com/openscad/openscad/blob/master/src/mainwin.cc#L1917-L1944 > > …where the Render (F6) summary report is generated. > > Andrew. > > On Nov 23, 2015, at 9:57 AM, clothbot <andrew@plumb.org> wrote: > > Total volume and center-of-mass could be calculated at export time, right > around here: > > https://github.com/openscad/openscad/blob/master/src/export.cc#L142-L187 > > Nice little overview of the math involved for volume here: > > http://n-e-r-v-o-u-s.com/blog/?p=4415 > > ...and for center of mass, aka "Centroid of a 3D shell described by 3 > vertex > facets": > > http://paulbourke.net/geometry/polygonmesh/ > > ...or... > > http://wwwf.imperial.ac.uk/~rn/centroid.pdf > > It's a bit more involved, but same underlying principles. > > Andrew. > > > > -- > View this message in context: > http://forum.openscad.org/Centre-of-Mass-tp14707p14714.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > -- > > "The future is already here. It's just not very evenly distributed" -- > William Gibson > > Me: http://clothbot.com/wiki/ > > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
AD
Ari Diacou
Tue, Nov 24, 2015 12:20 PM

Okay, fine, that is a good reason why all of my proposed variables should
not be referenceable in the language. Or at least be made so that they
can't be accessed by geometry. It would still be nice to perform
calculations on them for echo() purposes.

On Tue, Nov 24, 2015 at 5:04 AM, nop head nop.head@gmail.com wrote:

Even if it was reported it doesn't solve the original problem of adjusting
the model to have the com in a specified place unless you use trial and
error. Even if the com was available numerically in OpenSCAD it doesn't
solve the original problem. You need to write an equation for the com
dependent on the variable of the geometry you wish to change and then solve
it to create the geometry.
On Nov 24, 2015 12:52 AM, "Andrew Plumb" andrew@plumb.org wrote:

On second thoughts, a better place to calculate and report the 3D
volume(s) and centroid(s) or 2D area(s), centroids and perimeter length(s)
would be here:

https://github.com/openscad/openscad/blob/master/src/mainwin.cc#L1917-L1944

…where the Render (F6) summary report is generated.

Andrew.

On Nov 23, 2015, at 9:57 AM, clothbot andrew@plumb.org wrote:

Total volume and center-of-mass could be calculated at export time, right
around here:

https://github.com/openscad/openscad/blob/master/src/export.cc#L142-L187

Nice little overview of the math involved for volume here:

http://n-e-r-v-o-u-s.com/blog/?p=4415

...and for center of mass, aka "Centroid of a 3D shell described by 3
vertex
facets":

http://paulbourke.net/geometry/polygonmesh/

...or...

http://wwwf.imperial.ac.uk/~rn/centroid.pdf

It's a bit more involved, but same underlying principles.

Andrew.

--
View this message in context:
http://forum.openscad.org/Centre-of-Mass-tp14707p14714.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--

"The future is already here.  It's just not very evenly distributed" --
William Gibson

Me: http://clothbot.com/wiki/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Okay, fine, that is a good reason why all of my proposed variables should not be referenceable in the language. Or at least be made so that they can't be accessed by geometry. It would still be nice to perform calculations on them for echo() purposes. On Tue, Nov 24, 2015 at 5:04 AM, nop head <nop.head@gmail.com> wrote: > Even if it was reported it doesn't solve the original problem of adjusting > the model to have the com in a specified place unless you use trial and > error. Even if the com was available numerically in OpenSCAD it doesn't > solve the original problem. You need to write an equation for the com > dependent on the variable of the geometry you wish to change and then solve > it to create the geometry. > On Nov 24, 2015 12:52 AM, "Andrew Plumb" <andrew@plumb.org> wrote: > >> On second thoughts, a better place to calculate and report the 3D >> volume(s) and centroid(s) or 2D area(s), centroids and perimeter length(s) >> would be here: >> >> >> https://github.com/openscad/openscad/blob/master/src/mainwin.cc#L1917-L1944 >> >> …where the Render (F6) summary report is generated. >> >> Andrew. >> >> On Nov 23, 2015, at 9:57 AM, clothbot <andrew@plumb.org> wrote: >> >> Total volume and center-of-mass could be calculated at export time, right >> around here: >> >> https://github.com/openscad/openscad/blob/master/src/export.cc#L142-L187 >> >> Nice little overview of the math involved for volume here: >> >> http://n-e-r-v-o-u-s.com/blog/?p=4415 >> >> ...and for center of mass, aka "Centroid of a 3D shell described by 3 >> vertex >> facets": >> >> http://paulbourke.net/geometry/polygonmesh/ >> >> ...or... >> >> http://wwwf.imperial.ac.uk/~rn/centroid.pdf >> >> It's a bit more involved, but same underlying principles. >> >> Andrew. >> >> >> >> -- >> View this message in context: >> http://forum.openscad.org/Centre-of-Mass-tp14707p14714.html >> Sent from the OpenSCAD mailing list archive at Nabble.com. >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> >> -- >> >> "The future is already here. It's just not very evenly distributed" -- >> William Gibson >> >> Me: http://clothbot.com/wiki/ >> >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
TN
Tom.Nally@shell.com
Tue, Nov 24, 2015 1:21 PM

This is wordy and ends with a relatively small payoff, but what the heck...

In the offshore oil patch, the center of mass (we call it "center of gravity" or "cg") is of continual interest.  We calculate it when we lift skids(1) and large modules because the cg will always position itself directly below the hook.  So, if we want the skid to be plumb and level during the lift, we might have to vary the lengths of slings in order to vertically align the hook with the cg as closely as possible.

But even more important, we work hard on determining the cg for entire floating production systems, such as tension leg platforms.  These things weigh thousands of tons.  Knowing where the cg is allows the operator to flow water into the ballast tanks in correct amounts so that the platform can remain level.  The entire engineering task is referred to as "weight control".  We usually assign weight control to one or two guys, and they will update the data weekly or monthly during the design phase.  (For a very large system, design might take 3 to 5 years.)

But I only provide that lengthy introduction to tell you the tool we typically use to calculate center of gravity: Microsoft Excel.  Each engineer working on a subsystem will have to determine the weight and cg for his system, and he will very likely use Excel.  Then he will provide his information to the weight control guys who will use it to populate a large Excel database.  The weight control guys plot the change in weight and cg over the course of a project, which helps the managers imagine what the weight might be when the project is done.

Even for a small OpenScad-designed assembly with fewer than a dozen components, I would probably use Excel to determine the location of the cg.


(1) A "skid" is a collection of production equipment and piping mounted on a steel frame.  The frame is usually made from wide-flanged beams, and contains "padeyes" or "lifting eyes" to which shackles and slings can be attached.  When a skid is lifted to a platform, the crane cannot always place the skid in it's final position.  Often, it has to be set down on the "lay down deck" first.  From there, it is "skidded" into place using "tuggers".  A tugger is just the offshore term for a winch.

From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of nop head
Sent: Tuesday, November 24, 2015 4:04 AM
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Centre of Mass

Even if it was reported it doesn't solve the original problem of adjusting the model to have the com in a specified place unless you use trial and error. Even if the com was available numerically in OpenSCAD it doesn't solve the original problem. You need to write an equation for the com dependent on the variable of the geometry you wish to change and then solve it to create the geometry.
On Nov 24, 2015 12:52 AM, "Andrew Plumb" <andrew@plumb.orgmailto:andrew@plumb.org> wrote:
On second thoughts, a better place to calculate and report the 3D volume(s) and centroid(s) or 2D area(s), centroids and perimeter length(s) would be here:

https://github.com/openscad/openscad/blob/master/src/mainwin.cc#L1917-L1944

…where the Render (F6) summary report is generated.

Andrew.

On Nov 23, 2015, at 9:57 AM, clothbot <andrew@plumb.orgmailto:andrew@plumb.org> wrote:

Total volume and center-of-mass could be calculated at export time, right
around here:

https://github.com/openscad/openscad/blob/master/src/export.cc#L142-L187

Nice little overview of the math involved for volume here:

http://n-e-r-v-o-u-s.com/blog/?p=4415

...and for center of mass, aka "Centroid of a 3D shell described by 3 vertex
facets":

http://paulbourke.net/geometry/polygonmesh/

...or...

http://wwwf.imperial.ac.uk/~rn/centroid.pdf

It's a bit more involved, but same underlying principles.

Andrew.

--
View this message in context: http://forum.openscad.org/Centre-of-Mass-tp14707p14714.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.orgmailto:Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--

"The future is already here.  It's just not very evenly distributed" -- William Gibson

Me: http://clothbot.com/wiki/


OpenSCAD mailing list
Discuss@lists.openscad.orgmailto:Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

This is wordy and ends with a relatively small payoff, but what the heck... In the offshore oil patch, the center of mass (we call it "center of gravity" or "cg") is of continual interest. We calculate it when we lift skids(1) and large modules because the cg will always position itself directly below the hook. So, if we want the skid to be plumb and level during the lift, we might have to vary the lengths of slings in order to vertically align the hook with the cg as closely as possible. But even more important, we work hard on determining the cg for entire floating production systems, such as tension leg platforms. These things weigh thousands of tons. Knowing where the cg is allows the operator to flow water into the ballast tanks in correct amounts so that the platform can remain level. The entire engineering task is referred to as "weight control". We usually assign weight control to one or two guys, and they will update the data weekly or monthly during the design phase. (For a very large system, design might take 3 to 5 years.) But I only provide that lengthy introduction to tell you the tool we typically use to calculate center of gravity: Microsoft Excel. Each engineer working on a subsystem will have to determine the weight and cg for his system, and he will very likely use Excel. Then he will provide his information to the weight control guys who will use it to populate a large Excel database. The weight control guys plot the change in weight and cg over the course of a project, which helps the managers imagine what the weight might be when the project is done. Even for a small OpenScad-designed assembly with fewer than a dozen components, I would probably use Excel to determine the location of the cg. ****************** (1) A "skid" is a collection of production equipment and piping mounted on a steel frame. The frame is usually made from wide-flanged beams, and contains "padeyes" or "lifting eyes" to which shackles and slings can be attached. When a skid is lifted to a platform, the crane cannot always place the skid in it's final position. Often, it has to be set down on the "lay down deck" first. From there, it is "skidded" into place using "tuggers". A tugger is just the offshore term for a winch. From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of nop head Sent: Tuesday, November 24, 2015 4:04 AM To: OpenSCAD general discussion Subject: Re: [OpenSCAD] Centre of Mass Even if it was reported it doesn't solve the original problem of adjusting the model to have the com in a specified place unless you use trial and error. Even if the com was available numerically in OpenSCAD it doesn't solve the original problem. You need to write an equation for the com dependent on the variable of the geometry you wish to change and then solve it to create the geometry. On Nov 24, 2015 12:52 AM, "Andrew Plumb" <andrew@plumb.org<mailto:andrew@plumb.org>> wrote: On second thoughts, a better place to calculate and report the 3D volume(s) and centroid(s) or 2D area(s), centroids and perimeter length(s) would be here: https://github.com/openscad/openscad/blob/master/src/mainwin.cc#L1917-L1944 …where the Render (F6) summary report is generated. Andrew. On Nov 23, 2015, at 9:57 AM, clothbot <andrew@plumb.org<mailto:andrew@plumb.org>> wrote: Total volume and center-of-mass could be calculated at export time, right around here: https://github.com/openscad/openscad/blob/master/src/export.cc#L142-L187 Nice little overview of the math involved for volume here: http://n-e-r-v-o-u-s.com/blog/?p=4415 ...and for center of mass, aka "Centroid of a 3D shell described by 3 vertex facets": http://paulbourke.net/geometry/polygonmesh/ ...or... http://wwwf.imperial.ac.uk/~rn/centroid.pdf It's a bit more involved, but same underlying principles. Andrew. -- View this message in context: http://forum.openscad.org/Centre-of-Mass-tp14707p14714.html Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list Discuss@lists.openscad.org<mailto:Discuss@lists.openscad.org> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org -- "The future is already here. It's just not very evenly distributed" -- William Gibson Me: http://clothbot.com/wiki/ _______________________________________________ OpenSCAD mailing list Discuss@lists.openscad.org<mailto:Discuss@lists.openscad.org> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
C
clothbot
Tue, Nov 24, 2015 3:15 PM

Not directly, but what if there were special $volume, $area, $centroid
variables, similar to the $vpr, $vpt and $vpd in scope:

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#.24vpr.2C_.24vpt_and_.24vpd

A Render (F6) would populate them with non-zero values/vectors as
appropriate, to be used in the next iteration.

pla_density=1.25; // units: g/cm^3

mm3_per_cm3=pow(10,3); // STL unit is treated as mm in many 3DP flows

function
mass(volume,density=pla_density,dscale=1/mm3_per_cm3)=volumedensitydscale;

new_mass=mass($volume*$t);

translate(-$centroid*$t)
some_object(target_mass=1.0,previous_mass=new_mass);

...then things get really weird-fun when you animate.

Andrew.

nophead wrote

Even if it was reported it doesn't solve the original problem of adjusting
the model to have the com in a specified place unless you use trial and
error. Even if the com was available numerically in OpenSCAD it doesn't
solve the original problem. You need to write an equation for the com
dependent on the variable of the geometry you wish to change and then
solve
it to create the geometry.
On Nov 24, 2015 12:52 AM, "Andrew Plumb" <

andrew@

> wrote:

On second thoughts, a better place to calculate and report the 3D
volume(s) and centroid(s) or 2D area(s), centroids and perimeter
length(s)
would be here:

https://github.com/openscad/openscad/blob/master/src/mainwin.cc#L1917-L1944

…where the Render (F6) summary report is generated.

Andrew.

--
View this message in context: http://forum.openscad.org/Centre-of-Mass-tp14707p14743.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Not directly, but what if there were special $volume, $area, $centroid variables, similar to the $vpr, $vpt and $vpd in scope: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#.24vpr.2C_.24vpt_and_.24vpd A Render (F6) would populate them with non-zero values/vectors as appropriate, to be used in the next iteration. pla_density=1.25; // units: g/cm^3 mm3_per_cm3=pow(10,3); // STL unit is treated as mm in many 3DP flows function mass(volume,density=pla_density,dscale=1/mm3_per_cm3)=volume*density*dscale; new_mass=mass($volume*$t); translate(-$centroid*$t) some_object(target_mass=1.0,previous_mass=new_mass); ...then things get really weird-fun when you animate. Andrew. nophead wrote > Even if it was reported it doesn't solve the original problem of adjusting > the model to have the com in a specified place unless you use trial and > error. Even if the com was available numerically in OpenSCAD it doesn't > solve the original problem. You need to write an equation for the com > dependent on the variable of the geometry you wish to change and then > solve > it to create the geometry. > On Nov 24, 2015 12:52 AM, "Andrew Plumb" &lt; > andrew@ > &gt; wrote: > >> On second thoughts, a better place to calculate and report the 3D >> volume(s) and centroid(s) or 2D area(s), centroids and perimeter >> length(s) >> would be here: >> >> https://github.com/openscad/openscad/blob/master/src/mainwin.cc#L1917-L1944 >> >> …where the Render (F6) summary report is generated. >> >> Andrew. -- View this message in context: http://forum.openscad.org/Centre-of-Mass-tp14707p14743.html Sent from the OpenSCAD mailing list archive at Nabble.com.