直交座標を球面座標に変換するマクロです。
//**********************************************************************************
#macro Spherical_coordinates(Vp)
#local RR=vlength(Vp); #local Rh=vlength(< Vp.x, 0, Vp.z >);
#if(Rh!=0)
#if(Vp.z/Rh>=0) #local Sg=1; #else #local Sg=-1; #end
#local HH=Sg*acos(Vp.x/Rh);
#else #local HH=0; #end
#if(Vp.y/RR>=0) #local Sg=1; #else #local Sg=-1; #end
#local VV=Sg*acos(Rh/RR);
< RR, HH, VV >
#end
//**********************************************************************************
atan2 を使わない方法で変換しています。