直交座標を球面座標に変換します。
//**********************************************************************************
入力 Pv:直交座標 出力
//**********************************************************************************
#macro Spherical_cnv(Pv)
#local RR=vlength(Pv); #local Rh=vlength(< Pv.x, Pv.y, 0 >);
#if(Pv.x=0 & Pv.y=0) #local HH=0; #else #local HH=atan2(Pv.y,Pv.x); #end
#if(Rh=0 & Pv.z=0) #local VV=0; #else #local VV=atan2(Pv.z,Rh); #end
< RR,HH,VV >
#end
//**********************************************************************************
物体を曲線上に等間隔で配置します。
//**********************************************************************************
入力
S :二点間の弧長
V1:媒介変数の範囲 <始点,終点,刻み幅>
Fn:式の登録番号
//**********************************************************************************
#macro Arclen_obj_line(S,V1,Fn)
#local P1=Line_function(V1.x,Fn); #local Ps=P1;
#local Tp=V1.x; #while( Tp < V1.y )
#local L=0; #while( L < S )
#local Pe=Line_function(Tp+V1.z,Fn);
#local L=L+vlength(Pe-Ps);
#if(L>S) #local L=S; #else #local Ps=Pe; #local Tp=Tp+V1.z; #end
#end
#local P2=Line_function(Tp,Fn);
#local Pv=Spherical_cnv(P2-P1);
object { Obj_seg rotate <0,-degrees(Pv.z),degrees(Pv.y)> translate P1 }
#local P1=P2;
#end
#end
//**********************************************************************************
例) #local Fn=5; #local Sc=20; #local Rt=<30,0,10>; #local Tr=-40*z;
union { Arclen_line2(0.3/Sc,<-4,4,1/60,1/2>,Fn)
pigment { Lc } scale Sc rotate Rt translate Tr }
#local Obj_seg = sphere {0,0.3*2/Sc}
union { Arclen_obj_line(1/2,<-4,4,1/60>,Fn)
pigment { rgb <1,0,0> } scale Sc rotate Rt translate Tr }
例) #local F0 = finish { phong 1 reflection 0.1 }
#local Tl = texture { pigment { color rgb <1.000, 0.395, 0.607> } finish { F0 } }
#local Fn=5; #local Sc=20; #local Rt=<30,0,10>; #local Tr=-40*z;
#local Obj_seg = sphere { 0,1/2/2 no_reflection no_shadow }
union { Arclen_obj_line(1/2,<-4,4,1/60>,Fn)
texture { Tl } scale Sc rotate Rt translate Tr }