I have an object (objectA) and want to generate a new object (objectB) that
will have the top half of objectA intact plus the bottom of objectA
intersected with a cylinder.
So far I have this:
union() {
intersection() {
sphere(r=10);
translate([0, 0, 11])
cube(size=22, center=true);
}
intersection() {
sphere(r=10);
translate([0, 0, - 6 + 0.1]) // adding 0.1 just to make sure they
overlap
cylinder(r=5, h=12, center=true);
}
}
Is there a better way of doing it?
The object is not a sphere, but it gives the idea.
basile
--
View this message in context: http://forum.openscad.org/Intersection-tp11627.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Perhaps
union()
{
intersection() {
sphere(r=10);
translate([0, 0, 11])
cube(size=22, center=true);
}
intersection() {
translate([0, 0, - 6 + 0.1]) // adding 0.1 just to make sure they
overlap
cylinder(r=5, h=12, center=true);
translate([0,0,-6])
cube(24,center=true);
}
}
Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.
View this message in context: http://forum.openscad.org/Intersection-tp11627p11628.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
why did you change the sphere to a cube in the 2nd intersection?
In the sample code the objectA IS the sphere.
In my local copy the calls to both spheres will be replaced by calls to a
module that generates the desired object.
Maybe this clear things up.
union() {
intersection() {
objectA();
translate([0, 0, 11])
cube(size=22, center=true);
}
intersection() {
objectA();
translate([0, 0, - 6 + 0.1]) // adding 0.1 just to make sure they
overlap
cylinder(r=5, h=12, center=true);
}
}
module objectA() {
sphere(r=10);
}
--
View this message in context: http://forum.openscad.org/Intersection-tp11627p11629.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Any time you have the choice between a cube and anything more complex for masking operations, go with the cube for performance.
Andrew.
On Feb 13, 2015, at 6:17 AM, basile basile.laderchi@gmail.com wrote:
why did you change the sphere to a cube in the 2nd intersection?
In the sample code the objectA IS the sphere.
In my local copy the calls to both spheres will be replaced by calls to a
module that generates the desired object.
Maybe this clear things up.
union() {
intersection() {
objectA();
translate([0, 0, 11])
cube(size=22, center=true);
}
intersection() {
objectA();
translate([0, 0, - 6 + 0.1]) // adding 0.1 just to make sure they
overlap
cylinder(r=5, h=12, center=true);
}
}
module objectA() {
sphere(r=10);
}
--
View this message in context: http://forum.openscad.org/Intersection-tp11627p11629.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
basile wrote
why did you change the sphere to a cube in the 2nd intersection?
In the sample code the objectA IS the sphere.
In my local copy the calls to both spheres will be replaced by calls to a
module that generates the desired object.
Maybe this clear things up.
union() {
intersection() {
objectA();
translate([0, 0, 11])
cube(size=22, center=true);
}
intersection() {
objectA();
translate([0, 0, - 6 + 0.1]) // adding 0.1 just to make sure they
overlap
cylinder(r=5, h=12, center=true);
}
}
module objectA() {
sphere(r=10);
}
Well that was what you had. I assumed you were not happy with what you had.
Uf your original is correct then that is how to do it.
I assumed you were not happy with the latter bit, where the sphere caused
the curved bottom.
If you have a basic example you are happy with why ask for improvements. Set
theory of objects is really basic.
Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.
View this message in context: http://forum.openscad.org/Intersection-tp11627p11631.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
not necessarily better, but with OpenSCAD you could also have the module give
the transformation instead of the object:
module mytransformation()
{
intersection() {
children(0);
translate([0, 0, 11]) cube(size=22, center=true);
}
intersection() {
translate([0, 0, - 6 + 0.1]) cylinder(r=5, h=12, center=true); // adding
0.1 just to make sure they overlap
children(0);
}
}
mytransformation() sphere(10);
--
View this message in context: http://forum.openscad.org/Intersection-tp11627p11632.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
@hagen: the use of children sounds great.
I will definitely use it!
View this message in context: http://forum.openscad.org/Intersection-tp11627p11649.html
Sent from the OpenSCAD mailing list archive at Nabble.com.