|
![](/i/fill.gif) |
Jellby wrote:
> Hi all,
>
> I'd like to cut a torus off from a sphere or cylinder
> (difference{sphere{}torus{}}). It works ok, but I'd also like it to work
> when the torus intersects itself, i.e., when its "minor" radius is larger
> than the "major" one. If I do as before, I get two cusps shapes joined by
> an elongated shape, and I want to get rid of this last one, keeping only
> the two cusps. Is there some "trick" to get this other than further
> differentiating out this elongated shape or defining an isosurface?
>
> I'm talking of something like this, but without having to use and calculate
> the box:
>
> camera { location <0,0,-5> }
> light_source { <10,10,-10>, rgb 1 }
>
> #declare Rmin=1.1;
> #declare Rmaj=1.0;
> #if(Rmin>Rmaj)
> #declare X=Rmin*sqrt(1-Rmaj*Rmaj/(Rmin*Rmin));
Why not X=sqrt(Rmin*Rmin-Rmaj*Rmaj) ?
> #else
> #declare X=0;
> #end
> difference {
> sphere { 0, 1 pigment { color rgb 1 } }
> torus { Rmaj, Rmin pigment { color rgb <1,0,0> } }
> box { -X,X }
> }
>
> I could also use "clipped_by { box { -X,X inverse } }". Would this be more
> efficent than differentiating?
The difference is probably better.
You could also rewrite the difference like this:
difference {
sphere { 0, 1 pigment { color rgb 1 } }
torus { Rmaj, Rmin pigment { color rgb <1,0,0> } }
#if(Rmin>Rmaj)
sphere { 0,sqrt(Rmin*Rmin-Rmaj*Rmaj) }
#end
}
and then you don't need the earlier block of if-else-end code.
Regards,
John
Post a reply to this message
|
![](/i/fill.gif) |