Angle of a quaternion in polar form
(Quaternion overloading of standard MATLAB® function)
θ = angle(q, a)
angle(X) computes the angle of a quaternion in polar form. The polar form of a quaternion is q = A exp(μθ) where A is a real or complex modulus, μ is a unit pure quaternion, and θ is an angle. It is θ that is computed by this function.
The second parameter is optional. If omitted, the result will always be in the range (0, π), that is, the quaternion q is regarded as being in the upper half of a complex plane defined by the axis of q. A reference unit vector defining the direction of the positive imaginary axis of q may be supplied as the second parameter, in which case the result may be in the full range from -π to +π. This reference unit vector is used to define the north pole of a hemisphere of 3-space, so that if the axis of q lies in this hemisphere, the angle is in the range (0,π). If the axis of q lies in the other (southern) hemisphere, then the angle returned will lie in (π, 2*π).
The optional argument must be either the same size as q or be a scalar (in which case the same value is used for all elements of q).
>> angle(randq(2)) ans = 1.8062 1.5062 2.2535 1.9501