discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Centre of Mass

J
Jimmis98
Sun, Nov 22, 2015 11:15 PM

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.

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.
AC
Alan Cox
Mon, Nov 23, 2015 9:01 AM

On Sun, 22 Nov 2015 16:15:15 -0700 (MST)
Jimmis98 anonimos79violin@gmail.com 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

On Sun, 22 Nov 2015 16:15:15 -0700 (MST) Jimmis98 <anonimos79violin@gmail.com> 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
AD
Ari Diacou
Mon, Nov 23, 2015 1:00 PM

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 anonimos79violin@gmail.com
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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <anonimos79violin@gmail.com> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
C
clothbot
Mon, Nov 23, 2015 2:57 PM

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.

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.
AD
Ari Diacou
Mon, Nov 23, 2015 3:52 PM

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 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

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 <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 >
TP
Torsten Paul
Mon, Nov 23, 2015 4:14 PM

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.

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.
J
Jimmis98
Mon, Nov 23, 2015 4:31 PM

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?

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

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? -- View this message in context: http://forum.openscad.org/Centre-of-Mass-tp14707p14717.html Sent from the OpenSCAD mailing list archive at Nabble.com.
AD
Ari Diacou
Mon, Nov 23, 2015 4:40 PM

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 Torsten.Paul@gmx.de 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <Torsten.Paul@gmx.de> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
AC
Alan Cox
Mon, Nov 23, 2015 4:43 PM

On Mon, 23 Nov 2015 09:31:59 -0700 (MST)
Jimmis98 anonimos79violin@gmail.com 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

On Mon, 23 Nov 2015 09:31:59 -0700 (MST) Jimmis98 <anonimos79violin@gmail.com> 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
EN
Ed Nisley
Mon, Nov 23, 2015 6:26 PM

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

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