# File lib/facets/more/quaternion.rb, line 265 def Quaternion::polar(m,t1=0,t2=0,t3=0) # q= # m*cos(t1) # +m*sin(t1)cos(t2)i # +m*sin(t1)sin(t2)cos(t3)j # +m*sin(t1)sin(t2)sin(t3)k # m is known as the magnitude, # t1 is the amplitude(or angle) of the quaternion, # t2 and t3 are the latitude (or co-latitude) and longitude respectively. if m.kind_of?(Array) and (m.size==4); t1=m[1]; t2=m[2]; t3=m[3]; m=m[0]; end; s=m r_part=s*Math.cos(t1); s=s*Math.sin(t1) i_part=s*Math.cos(t2); s=s*Math.sin(t2) j_part=s*Math.cos(t3); k_part=s*Math.sin(t3) new(r_part, i_part, j_part, k_part) end