discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Projection volume

E
emmanueliarussi
Tue, Jan 3, 2017 1:58 PM

Hello,
I was wondering if there is a way in OpenSCAD to get the projection volume
of a shape.
Let's say I have an imported mesh, I want the volume generated by projecting
it onto a plane (xy in my case). Thanks!

--
View this message in context: http://forum.openscad.org/Projection-volume-tp19885.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hello, I was wondering if there is a way in OpenSCAD to get the projection volume of a shape. Let's say I have an imported mesh, I want the volume generated by projecting it onto a plane (xy in my case). Thanks! -- View this message in context: http://forum.openscad.org/Projection-volume-tp19885.html Sent from the OpenSCAD mailing list archive at Nabble.com.
MK
Marius Kintel
Tue, Jan 3, 2017 2:35 PM

You cannot measure the volume in OpenSCAD, but you can create the shape like this:

module MyShape() translate([0,0,30]) sphere(20);

hull() {
MyShape();
linear_extrude(height=1) projection() MyShape();
}

-Marius

On Jan 3, 2017, at 08:58, emmanueliarussi emmanueliarussi@gmail.com wrote:

Hello,
I was wondering if there is a way in OpenSCAD to get the projection volume
of a shape.
Let's say I have an imported mesh, I want the volume generated by projecting
it onto a plane (xy in my case). Thanks!

You cannot measure the volume in OpenSCAD, but you can create the shape like this: module MyShape() translate([0,0,30]) sphere(20); hull() { MyShape(); linear_extrude(height=1) projection() MyShape(); } -Marius On Jan 3, 2017, at 08:58, emmanueliarussi <emmanueliarussi@gmail.com> wrote: > > Hello, > I was wondering if there is a way in OpenSCAD to get the projection volume > of a shape. > Let's say I have an imported mesh, I want the volume generated by projecting > it onto a plane (xy in my case). Thanks!
E
emmanueliarussi
Tue, Jan 3, 2017 2:52 PM

Right, that's the way I'm doing it now, but only works for convex shapes (as
the sphere). Otherwise, the hull() destroys the non-convexities and holes in
the original shape. I was looking for a more general solution.

--
View this message in context: http://forum.openscad.org/Projection-volume-tp19885p19887.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Right, that's the way I'm doing it now, but only works for convex shapes (as the sphere). Otherwise, the hull() destroys the non-convexities and holes in the original shape. I was looking for a more general solution. -- View this message in context: http://forum.openscad.org/Projection-volume-tp19885p19887.html Sent from the OpenSCAD mailing list archive at Nabble.com.
RP
Ronaldo Persiano
Tue, Jan 3, 2017 3:03 PM

A very slow solution that works with non-convex shapes is:

module MyShape() { translate([0,0,30]) sphere(20); translate([0,15,20])
sphere(20); }

intersection() {
minkowski() {
MyShape();
translate([0,0,-100]) cylinder(d=0.001,h=100);
}
translate([0,0,50]) cube([100,100,100],center=true);
}

2017-01-03 12:52 GMT-02:00 emmanueliarussi emmanueliarussi@gmail.com:

Right, that's the way I'm doing it now, but only works for convex shapes
(as
the sphere). Otherwise, the hull() destroys the non-convexities and holes
in
the original shape. I was looking for a more general solution.

--
View this message in context: http://forum.openscad.org/Projection-volume-
tp19885p19887.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

A very slow solution that works with non-convex shapes is: module MyShape() { translate([0,0,30]) sphere(20); translate([0,15,20]) sphere(20); } intersection() { minkowski() { MyShape(); translate([0,0,-100]) cylinder(d=0.001,h=100); } translate([0,0,50]) cube([100,100,100],center=true); } 2017-01-03 12:52 GMT-02:00 emmanueliarussi <emmanueliarussi@gmail.com>: > Right, that's the way I'm doing it now, but only works for convex shapes > (as > the sphere). Otherwise, the hull() destroys the non-convexities and holes > in > the original shape. I was looking for a more general solution. > > > > -- > View this message in context: http://forum.openscad.org/Projection-volume- > tp19885p19887.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 >
E
emmanueliarussi
Tue, Jan 3, 2017 3:52 PM

That did the trick. Thanks a lot Ronaldo!  I'll now try to run my code in a
faster computer.

Ronaldo wrote

A very slow solution that works with non-convex shapes is:

module MyShape() { translate([0,0,30]) sphere(20); translate([0,15,20])
sphere(20); }

intersection() {
minkowski() {
MyShape();
translate([0,0,-100]) cylinder(d=0.001,h=100);
}
translate([0,0,50]) cube([100,100,100],center=true);
}

2017-01-03 12:52 GMT-02:00 emmanueliarussi <

emmanueliarussi@

>:

Right, that's the way I'm doing it now, but only works for convex shapes
(as
the sphere). Otherwise, the hull() destroys the non-convexities and holes
in
the original shape. I was looking for a more general solution.

--
View this message in context:
http://forum.openscad.org/Projection-volume-
tp19885p19887.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list

Discuss@.openscad

Discuss@.openscad

--
View this message in context: http://forum.openscad.org/Projection-volume-tp19885p19891.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

That did the trick. Thanks a lot Ronaldo! I'll now try to run my code in a faster computer. Ronaldo wrote > A very slow solution that works with non-convex shapes is: > > module MyShape() { translate([0,0,30]) sphere(20); translate([0,15,20]) > sphere(20); } > > intersection() { > minkowski() { > MyShape(); > translate([0,0,-100]) cylinder(d=0.001,h=100); > } > translate([0,0,50]) cube([100,100,100],center=true); > } > > 2017-01-03 12:52 GMT-02:00 emmanueliarussi &lt; > emmanueliarussi@ > &gt;: > >> Right, that's the way I'm doing it now, but only works for convex shapes >> (as >> the sphere). Otherwise, the hull() destroys the non-convexities and holes >> in >> the original shape. I was looking for a more general solution. >> >> >> >> -- >> View this message in context: >> http://forum.openscad.org/Projection-volume- >> tp19885p19887.html >> Sent from the OpenSCAD mailing list archive at Nabble.com. >> >> _______________________________________________ >> OpenSCAD mailing list >> > Discuss@.openscad >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@.openscad > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org -- View this message in context: http://forum.openscad.org/Projection-volume-tp19885p19891.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Tue, Jan 3, 2017 4:50 PM

Just another good reason for generalizing the implementation of
linear_extrude() to operate over 3D-objects. We had some discussion about
this, see
http://forum.openscad.org/Non-Linear-Transformations-tp14539p16673.html

--
View this message in context: http://forum.openscad.org/Projection-volume-tp19885p19892.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Just another good reason for generalizing the implementation of linear_extrude() to operate over 3D-objects. We had some discussion about this, see http://forum.openscad.org/Non-Linear-Transformations-tp14539p16673.html -- View this message in context: http://forum.openscad.org/Projection-volume-tp19885p19892.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Tue, Jan 3, 2017 5:06 PM

I think this gives the correct result in a timely manner:

module MyShape() { translate([0,0,30]) sphere(20); translate([0,15,20])
sphere(20); }

eps = 1/80;
inf = 100;

intersection() {
hull() {
MyShape();

    linear_extrude(height = eps, convexity = 2)
        projection()
            MyShape();
}
linear_extrude(height = inf, convexity = 2)
    projection()
        MyShape();

}

On 3 January 2017 at 16:50, Parkinbot rudolf@parkinbot.com wrote:

Just another good reason for generalizing the implementation of
linear_extrude() to operate over 3D-objects. We had some discussion about
this, see
http://forum.openscad.org/Non-Linear-Transformations-tp14539p16673.html

--
View this message in context: http://forum.openscad.org/Projection-volume-
tp19885p19892.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 think this gives the correct result in a timely manner: module MyShape() { translate([0,0,30]) sphere(20); translate([0,15,20]) sphere(20); } eps = 1/80; inf = 100; intersection() { hull() { MyShape(); linear_extrude(height = eps, convexity = 2) projection() MyShape(); } linear_extrude(height = inf, convexity = 2) projection() MyShape(); } On 3 January 2017 at 16:50, Parkinbot <rudolf@parkinbot.com> wrote: > Just another good reason for generalizing the implementation of > linear_extrude() to operate over 3D-objects. We had some discussion about > this, see > http://forum.openscad.org/Non-Linear-Transformations-tp14539p16673.html > > > > -- > View this message in context: http://forum.openscad.org/Projection-volume- > tp19885p19892.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 >
NH
nop head
Tue, Jan 3, 2017 5:09 PM

Or perhaps not, sorry!

On 3 January 2017 at 17:06, nop head nop.head@gmail.com wrote:

I think this gives the correct result in a timely manner:

module MyShape() { translate([0,0,30]) sphere(20); translate([0,15,20])
sphere(20); }

eps = 1/80;
inf = 100;

intersection() {
hull() {
MyShape();

     linear_extrude(height = eps, convexity = 2)
         projection()
             MyShape();
 }
 linear_extrude(height = inf, convexity = 2)
     projection()
         MyShape();

}

On 3 January 2017 at 16:50, Parkinbot rudolf@parkinbot.com wrote:

Just another good reason for generalizing the implementation of
linear_extrude() to operate over 3D-objects. We had some discussion about
this, see
http://forum.openscad.org/Non-Linear-Transformations-tp14539p16673.html

--
View this message in context: http://forum.openscad.org/Proj
ection-volume-tp19885p19892.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

Or perhaps not, sorry! On 3 January 2017 at 17:06, nop head <nop.head@gmail.com> wrote: > I think this gives the correct result in a timely manner: > > module MyShape() { translate([0,0,30]) sphere(20); translate([0,15,20]) > sphere(20); } > > eps = 1/80; > inf = 100; > > intersection() { > hull() { > MyShape(); > > linear_extrude(height = eps, convexity = 2) > projection() > MyShape(); > } > linear_extrude(height = inf, convexity = 2) > projection() > MyShape(); > } > > > On 3 January 2017 at 16:50, Parkinbot <rudolf@parkinbot.com> wrote: > >> Just another good reason for generalizing the implementation of >> linear_extrude() to operate over 3D-objects. We had some discussion about >> this, see >> http://forum.openscad.org/Non-Linear-Transformations-tp14539p16673.html >> >> >> >> -- >> View this message in context: http://forum.openscad.org/Proj >> ection-volume-tp19885p19892.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 >> > >
R
Ronaldo
Tue, Jan 3, 2017 5:33 PM

Parkinbot wrote

Just another good reason for generalizing the implementation of
linear_extrude() to operate over 3D-objects. We had some discussion about
this, see
http://forum.openscad.org/Non-Linear-Transformations-tp14539p16673.html

Or a good reason to generalize minkowski to accept 1D and 2D objects as well
defined in mathematics. The minkowski of a line segment and a solid is much
easier to compute.

--
View this message in context: http://forum.openscad.org/Projection-volume-tp19885p19895.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Parkinbot wrote > Just another good reason for generalizing the implementation of > linear_extrude() to operate over 3D-objects. We had some discussion about > this, see > http://forum.openscad.org/Non-Linear-Transformations-tp14539p16673.html Or a good reason to generalize minkowski to accept 1D and 2D objects as well defined in mathematics. The minkowski of a line segment and a solid is much easier to compute. -- View this message in context: http://forum.openscad.org/Projection-volume-tp19885p19895.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Tue, Jan 3, 2017 10:26 PM

Ronaldo wrote

Or a good reason to generalize minkowski to accept 1D and 2D objects as
well defined in mathematics. The minkowski of a line segment and a solid
is much easier to compute.

This would mean to include 1D objects into OpenSCAD first and
redefine/expand/reimplement all operations and so on, as already discussed.
A lot of work.

BTW, letting scale and twist aside linear_extrude() IS a minkowski_z()
operator. While it is easy to implement for 2D objects, implementing it on
general 3D objects can get nasty.

--
View this message in context: http://forum.openscad.org/Projection-volume-tp19885p19906.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Ronaldo wrote > Or a good reason to generalize minkowski to accept 1D and 2D objects as > well defined in mathematics. The minkowski of a line segment and a solid > is much easier to compute. This would mean to include 1D objects into OpenSCAD first and redefine/expand/reimplement all operations and so on, as already discussed. A lot of work. BTW, letting scale and twist aside linear_extrude() IS a minkowski_z() operator. While it is easy to implement for 2D objects, implementing it on general 3D objects can get nasty. -- View this message in context: http://forum.openscad.org/Projection-volume-tp19885p19906.html Sent from the OpenSCAD mailing list archive at Nabble.com.