La macro nel dettaglio
Per questo consideriamio due casi:
1. abs(Segment_Angle) <= 180 gradi (solo un'intersezione di un toro e due scatole) e
2. abs(Segment_Angle) > 180 gradi (un'intersezione di un toro e l'unione di due scatole):
//--------------------------------------------------------Segment_of_Torus
#macro Segment_of_Torus ( R_major, R_minor, Segment_Angle)
//---------------------------------------------------------------------------
#local D = 0.00001;
#if (Segment_Angle < 0)
#local Negativ_Flag = 1;
#local Segment_Angle = -Segment_Angle;
#else
#local Negativ_Flag = 0;
#end
#if (Segment_Angle > 360) #local Segment_Angle = mod(Segment_Angle,360); #end
intersection{
torus { R_major, R_minor }
#if (Segment_Angle > 180)
union{
#end // use union!
box { <-1,-1,0>,<1,1,1>
scale < R_major+R_minor+D, R_minor+D, R_major+R_minor+D>
}// end of box
box { <-1,-1,-1>,<1,1,0>
scale < R_major+R_minor+D, R_minor+D, R_major+R_minor+D>
rotate < 0,-Segment_Angle,0 >
}// end of box
#if (Segment_Angle > 180)
}
#end // end of union, if union is used!
#if (Negativ_Flag = 0) rotate<0, Segment_Angle,0> #end
} // end of intersection
#end // -------------------------- end of macro Segment_of_Torus |
Le immagini seguenti mostrano come lavora questa macro
(i box sono visualizati in testura "glass"):
|
abs(Segment_Angle) <= 180 degrees R_major = 1.00, R_minor = 0.25, Angle = -145
|
abs(Segment_Angle) > 180 degrees R_major = 1.00, R_minor = 0.25, Angle = -215
|
|