Navigation

Operators and Keywords

Function List:

C++ API

Function File: [axis, angle] = q2rot (q)

Function File: [axis, angle, qn] = q2rot (q)

Extract vector/angle form of a unit quaternion q.

Inputs

q
Unit quaternion describing the rotation. Quaternion q can be a scalar or an array. In the latter case, q is reshaped to a row vector and the return values axis and angle are concatenated horizontally, accordingly.

Outputs

axis
Eigenaxis as a 3-d unit vector [x; y; z]. If input argument q is a quaternion array, axis becomes a matrix where axis(:,i) corresponds to q(i).
angle
Rotation angle in radians. The positive direction is determined by the right-hand rule applied to axis. The angle lies in the interval [0, 2*pi]. If input argument q is a quaternion array, angle becomes a row vector where angle(i) corresponds to q(i).
qn
Optional output of diagnostic nature. qn = reshape (q, 1, []) or, if needed, qn = reshape (unit (q), 1, []).

Example

          octave:1> axis = [0; 0; 1]
          axis =
          
             0
             0
             1
          
          octave:2> angle = pi/4
          angle =  0.78540
          octave:3> q = rot2q (axis, angle)
          q = 0.9239 + 0i + 0j + 0.3827k
          octave:4> [vv, th] = q2rot (q)
          vv =
          
             0
             0
             1
          
          th =  0.78540
          octave:5> theta = th*180/pi
          theta =  45.000
          octave:6>

Package: quaternion