POV−Rayによる描き方

 POV-Rayは、基本的には左手座標系であるが、次に示す指定を行い、数学と同じ、右手座標系にして使用する。
camera { location -400*y right -4/3*x sky z look_at 0 angle 60 } // right-handed coordinate system

 使用する変数名は、動径rをRr、長半径aをAX、離心率eをEC、偏角θをTpとする。

 楕円を描く為の呼び出し方は、
 union { Ellipse_orbit(Lr ,< 0 ,2*pi ,pi/26 > ,EC ,AX ,0) texture { T_orbit } } である。
 unionで、sphereで表した点と、cylinderで表した線分を結合する。
 描く曲線の太さを半径Lrで指定し、曲線の始点Ts、終点Te、刻み幅Taを、ベクトルPrの成分として<Ts ,Te ,Ta>で与える。(POV-Ray ではπをpiと記述する)
 #switch 文の#case(0)に、描く曲線の式を定義しているので、Func_noには 0 を指定する。
 texture で、楕円の線に色を付けます。T_orbitは、その色の定義名です。
//****************************************************************
#local F1 = finish { ambient 0.1 diffuse 0.6 specular 0.5 }
#local T_orbit = texture { pigment { color rgb < 0.021, 0.499, 0.579 > } finish { F1 } }
//****************************************************************
#macro Orbit_func(EC ,AX ,Tp ,Func_no)
#switch(Func_no)
#case(0) #local Rr=AX*(1-pow(EC,2))/(1+EC*cos(Tp)); #local P=< Rr*cos(Tp) , Rr*sin(Tp) >; #break
#end P
#end
//----------------------------------------------------------------------------------
#macro Ellipse_orbit(Lr ,Pr ,EC ,AX ,Func_no)
#local Ts=Pr.x; #local Te=Pr.y; #local Ta=Pr.z;
#while( Ts < Te )
#local P1=Orbit_func(EC ,AX ,Ts ,Func_no);
#local P2=Orbit_func(EC ,AX ,Ts+Ta ,Func_no);
sphere { P1, Lr } cylinder { P1, P2, Lr }
#local Ts=Ts+Ta; #end
#end
//****************************************************************