Centre of Mass

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Centre of Mass

Jimmis98
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

Alan Cox
On Sun, 22 Nov 2015 16:15:15 -0700 (MST)
Jimmis98 <[hidden email]> wrote:

> Hello.
> I am creating a model of a car. I am going to actually build it from balsa
> wood and ABS plastic. I would like the centre of mass of the model to be in
> the middle of the distance between the front and rear wheels. I have reached
> a point where the rear wheels is in position and I can move the location of
> the front wheels parametrically. Is there a way to find the centre of mass
> of the model, assuming it is made of a material of fixed density along its
> volume (or maybe two materials, seeing that I will eventually work with two
> as it is), and then have the front wheel relocate itself accordingly every
> time I make a change and the centre of mass changes?
> Additionally, is there a way to find the mass of an object?
> Sorry if I am asking things that have no point of being asked in this forum
> or have already been asked.

OpenSCAD can't do it, but for a uniform material Meshlab can. See

http://gazebosim.org/tutorials?tut=inertia&cat=build_robot


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

drxenocide
In reply to this post by Jimmis98
As far as I know, there is no short way to find the COM of a model.

Of course, if the model is of uniform density, then the center of mass is just related to the center of volume. You could find the volume of each item in your assembly, and then scalar multiply that by the translation vectors, add them all together, and divide by the total mass to get the COM.

In general, OpenSCAD does not have functions which ask questions about the model that has been made.

Good luck.



On Sun, Nov 22, 2015 at 6:15 PM, Jimmis98 <[hidden email]> wrote:
Hello.
I am creating a model of a car. I am going to actually build it from balsa
wood and ABS plastic. I would like the centre of mass of the model to be in
the middle of the distance between the front and rear wheels. I have reached
a point where the rear wheels is in position and I can move the location of
the front wheels parametrically. Is there a way to find the centre of mass
of the model, assuming it is made of a material of fixed density along its
volume (or maybe two materials, seeing that I will eventually work with two
as it is), and then have the front wheel relocate itself accordingly every
time I make a change and the centre of mass changes?
Additionally, is there a way to find the mass of an object?
Sorry if I am asking things that have no point of being asked in this forum
or have already been asked.



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

clothbot
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.
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

drxenocide
I would love to have some functions that calculate information about the model:
facets,
edges,
estimated hard disk space for a given export e.g. storage_space(type="stl")
volume,
surface area,
principal rotation axes, (output as a matrix?)
center of mass,
surface area that intersects a given plane,
a way to get a point plane or line segment on the surface of a 2D or 3D shape (im thinking some way that we could at least find the farthest or nearest point to the center of mass),
contour length of a slice intersecting a given plane, 
estimated filament volume as a function of shell thickness and fill percentage (although we could do that ourselves with the above functions)

It would also be nice if each of these functions could work on a tree of code e.g.

module widget(){...}
f=facets(widget());
echo(f);

and if no code were passed to facets() then it would calculate it based on the whole model.

I would, of course, also like: them to be implemented in the next release, with good documentation, in the exact method i described, and a pony. kthxbai.


On Mon, Nov 23, 2015 at 9:57 AM, clothbot <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

tp3
On 11/23/2015 04:52 PM, Ari Diacou wrote:
> I would love to have some functions that calculate information about
> the model:
>
Hmm, most of that information (when applied to the final rendered model)
could be generated by some post processing. This could be a nice candidate
for a very simple plug-in interface as discussed in a different thread.

I think there's an issue on github asking for something in that
direction. With a more general approach, it could cover lots of things
(e.g. call a slicer, upload to some webservice like octoprint, calculate
information).

All that would mean it's strictly a GUI feature, the language itself
does not need to know anything about this.

> I would, of course, also like: them to be implemented in the next
> release, with good documentation, in the exact method i described,
> and a pony. kthxbai.
>
No unicorn? Where's the challenge then? ;-)

ciao,
  Torsten.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

Jimmis98
This post was updated on .
In reply to this post by Jimmis98
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

drxenocide
In reply to this post by tp3
I was hoping for them inside the language.

Most of these things I wanted when I was designing this thing: http://www.thingiverse.com/thing:487090/#files

It was a climbing hold for a rock wall. The basic code was:

module rock(){
    hull(){
        for(i=1:n){
             translate(random_3_array[i]) 
                  sphere(r=random_size[i]);
            }
        }
    }

module hold(){
    difference(){
        rock();
        translate([0,0,-about half the size of rock()])
             cube(slightly larger than the size of rock()) //cuts off bottom half of rock
        bore(); //so I can drill a bolt into it
        }
    }

But because this was before list manipulations, I had no idea how big my random blob was going to be, or how far down I should drill the bore.

These are the kinds of operations that would be far easier if I had access to them in the language, rather than as a plugin.

Or am I misunderstanding, and plugins could could be accessed in-language somehow?

On Mon, Nov 23, 2015 at 11:14 AM, Torsten Paul <[hidden email]> wrote:
On 11/23/2015 04:52 PM, Ari Diacou wrote:
> I would love to have some functions that calculate information about
> the model:
>
Hmm, most of that information (when applied to the final rendered model)
could be generated by some post processing. This could be a nice candidate
for a very simple plug-in interface as discussed in a different thread.

I think there's an issue on github asking for something in that
direction. With a more general approach, it could cover lots of things
(e.g. call a slicer, upload to some webservice like octoprint, calculate
information).

All that would mean it's strictly a GUI feature, the language itself
does not need to know anything about this.

> I would, of course, also like: them to be implemented in the next
> release, with good documentation, in the exact method i described,
> and a pony. kthxbai.
>
No unicorn? Where's the challenge then? ;-)

ciao,
  Torsten.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

Alan Cox
In reply to this post by Jimmis98
On Mon, 23 Nov 2015 09:31:59 -0700 (MST)
Jimmis98 <[hidden email]> wrote:

> So, basically, it is not yet supported by OpenSCAD itself and I will have
> better luck either changing software or using an additional external tool.
> Amirite?

Yeah - just export the model as STL and load it into the relevant tool
like meshlab. There are lots of things OpenSCAD doesn't do - and in most
cases that is a good thing.

Alan

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

ednisley
In reply to this post by drxenocide
On 11/23/2015 11:40 AM, Ari Diacou wrote:
> I had no idea how big my random blob was going to be, or how far down I
> should drill the bore.

You can create constants (a.k.a "variables") from the random values,
then use their values (perhaps in vectors) to build / translate rocks &
holes & slicing planes:

RockOD = rands(20,50,1)[0];
HoleOD = rands(3,5,1)[0];
HoleSides = rands(3,8,1)[0];

echo(str("Rock dia: ",RockOD));
echo(str("Hole dia: ",HoleOD));

difference() {
     sphere(d=RockOD);
#   cylinder(d=HoleOD,h=2*RockOD,$fn=HoleSides,center=true);
     translate([0,0,-RockOD/2])
         cube([2*RockOD,2*RockOD,RockOD],center=true);
}


Granted that you can't reach into the model to get mesh features, but
you can certainly use the /dimensions/ of the overall structure, because
you know them already!

--
Ed
softsolder.com

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
 --
Ed
softsolder.com
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

clothbot
In reply to this post by clothbot
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:


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

Andrew.

On Nov 23, 2015, at 9:57 AM, clothbot <[hidden email]> 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
[hidden email]
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

nophead

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" <[hidden email]> 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:


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

Andrew.

On Nov 23, 2015, at 9:57 AM, clothbot <[hidden email]> 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
[hidden email]
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

drxenocide
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 <[hidden email]> 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" <[hidden email]> 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:


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

Andrew.

On Nov 23, 2015, at 9:57 AM, clothbot <[hidden email]> 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
[hidden email]
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

Tom.Nally
In reply to this post by nophead

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:[hidden email]] 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" <[hidden email]> 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:

 

 

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

 

Andrew.

 

On Nov 23, 2015, at 9:57 AM, clothbot <[hidden email]> 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
[hidden email]
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Centre of Mass

clothbot
In reply to this post by nophead
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" <[hidden email]> 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.