discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Fill with color intersection between two solid objects

A
Aleandro
Wed, May 2, 2018 12:26 PM

Dear all,
Is is possible to fill with a given color the volume given by the
intersection between two solid 3D objects in OpenSCAD? For example, I would
like the intersection between the two spheres in the example to be in blue.

color([1,0,0,0.5]) translate([0.5,0,0]) sphere(1,$fn=100);
color([1,0,0,0.5]) translate([2,0,0]) sphere(1,$fn=100);

Tank you for your help.

--
Sent from: http://forum.openscad.org/

Dear all, Is is possible to fill with a given color the volume given by the intersection between two solid 3D objects in OpenSCAD? For example, I would like the intersection between the two spheres in the example to be in blue. color([1,0,0,0.5]) translate([0.5,0,0]) sphere(1,$fn=100); color([1,0,0,0.5]) translate([2,0,0]) sphere(1,$fn=100); Tank you for your help. -- Sent from: http://forum.openscad.org/
NH
nop head
Wed, May 2, 2018 12:43 PM

Yes, sort of.

color("blue") intersection() {
translate([0.5,0,0]) sphere(1,$fn=100);
translate([2,0,0]) sphere(1,$fn=100);
}

color([1,0,0,0.5]) translate([0.5,0,0]) sphere(1,$fn=100);
color([1,0,0,0.5]) translate([2,0,0]) sphere(1,$fn=100);

On 2 May 2018 at 13:26, Aleandro michele.roma@hotmail.it wrote:

Dear all,
Is is possible to fill with a given color the volume given by the
intersection between two solid 3D objects in OpenSCAD? For example, I would
like the intersection between the two spheres in the example to be in blue.

color([1,0,0,0.5]) translate([0.5,0,0]) sphere(1,$fn=100);
color([1,0,0,0.5]) translate([2,0,0]) sphere(1,$fn=100);

Tank you for your help.

--
Sent from: http://forum.openscad.org/


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

Yes, sort of. color("blue") intersection() { translate([0.5,0,0]) sphere(1,$fn=100); translate([2,0,0]) sphere(1,$fn=100); } color([1,0,0,0.5]) translate([0.5,0,0]) sphere(1,$fn=100); color([1,0,0,0.5]) translate([2,0,0]) sphere(1,$fn=100); On 2 May 2018 at 13:26, Aleandro <michele.roma@hotmail.it> wrote: > Dear all, > Is is possible to fill with a given color the volume given by the > intersection between two solid 3D objects in OpenSCAD? For example, I would > like the intersection between the two spheres in the example to be in blue. > > color([1,0,0,0.5]) translate([0.5,0,0]) sphere(1,$fn=100); > color([1,0,0,0.5]) translate([2,0,0]) sphere(1,$fn=100); > > > Tank you for your help. > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
A
Aleandro
Wed, May 2, 2018 3:24 PM

Thank you. This colors in blue only one of the two 'lenses' that form the
surface of the intersection. Is there a way to color the entire surface?

best,

--
Sent from: http://forum.openscad.org/

Thank you. This colors in blue only one of the two 'lenses' that form the surface of the intersection. Is there a way to color the entire surface? best, -- Sent from: http://forum.openscad.org/
NH
nop head
Wed, May 2, 2018 4:16 PM

The entire intersection is blue when viewed on its own. It shows up blue if
you make the spheres more transparent.

The reason it looks different when viewed through one sphere compared to
the other is the due to the lighting. When viewed from the side away from
the light the blue is darker and doesn't show as well through the red.

Also you can only see one sphere through the other due to the order they
are drawn.

On 2 May 2018 at 16:24, Aleandro michele.roma@hotmail.it wrote:

Thank you. This colors in blue only one of the two 'lenses' that form the
surface of the intersection. Is there a way to color the entire surface?

best,

--
Sent from: http://forum.openscad.org/


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

The entire intersection is blue when viewed on its own. It shows up blue if you make the spheres more transparent. The reason it looks different when viewed through one sphere compared to the other is the due to the lighting. When viewed from the side away from the light the blue is darker and doesn't show as well through the red. Also you can only see one sphere through the other due to the order they are drawn. On 2 May 2018 at 16:24, Aleandro <michele.roma@hotmail.it> wrote: > Thank you. This colors in blue only one of the two 'lenses' that form the > surface of the intersection. Is there a way to color the entire surface? > > best, > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
R
runsun
Wed, May 2, 2018 4:38 PM

This might give you some visual idea:

module obj1() sphere(1,$fn=100);
module obj2() translate([1.5,0,0]) obj1();
module inter() intersection() {obj1();obj2(2);}

color("gold")
{
translate( [-0.3,0,0] )
difference() {obj1();inter();}
translate( [0.3,0,0] )
difference() {obj2();inter();}
}
color("blue")inter();


$  Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText  ( OpenSCAD lexer ); $ Tips ; $ Snippets

--
Sent from: http://forum.openscad.org/

This might give you some visual idea: module obj1() sphere(1,$fn=100); module obj2() translate([1.5,0,0]) obj1(); module inter() intersection() {obj1();obj2(2);} color("gold") { translate( [-0.3,0,0] ) difference() {obj1();inter();} translate( [0.3,0,0] ) difference() {obj2();inter();} } color("blue")inter(); ----- $ Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText ( OpenSCAD lexer );&nbsp;$ Tips ;&nbsp;$ Snippets -- Sent from: http://forum.openscad.org/