// Last edited on 2023-06-12 20:49:30 by stolfi #macro curvsamp_torus(Rt,rt, vd, vr, show_axes, tx) // Returns one of the tori of a tetratorus. // {Rt}, {rt} major and minor radii of the tori. // {vr} direction (unnormalized) of the torus' rotation axis. // {vd} displacement vector. // {show_axes} show the local basis of each torus. // Two vectors orthogonal to each other and to {vr}: #if (vr.x != 0) #local vs = < +vr.y, -vr.x, 0 >; #else #local vs = < 0, -vr.z, vr.y >; #end #local vt = vcross(vr, vs); #local ur = vr/vlength(vr); #local us = vs/vlength(vs); #local ut = vt/vlength(vt); #debug concat("matrix = {\n") #debug concat(" { ", str(ur.x,11,8), ", ", str(ur.y,11,8), ", ", str(ur.z,11,8) " }\n") #debug concat(" { ", str(us.x,11,8), ", ", str(us.y,11,8), ", ", str(us.z,11,8) " }\n") #debug concat(" { ", str(ut.x,11,8), ", ", str(ut.y,11,8), ", ", str(ut.z,11,8) " }\n") #debug concat("}\n") #debug concat("displacement = { ", str(vd.x,11,8), ", ", str(vd.y,11,8), ", ", str(vd.z,11,8) " }\n") union{ torus{ Rt, rt texture{ tx } } #if (show_axes) object{ eixos( 1.75*Rt, 0.05*rt ) } #end matrix< us.x, us.y, us.z, ur.x, ur.y, ur.z, ut.x, ut.y, ut.z, vd.x, vd.y, vd.z > } #end