Function File: q = rot2q (axis, angle)
Create unit quaternion q which describes a rotation of angle radians about the vector axis. This function uses the active convention where the vector axis is rotated by angle radians. If the coordinate frame should be rotated by angle radians, also called the passive convention, this is equivalent to rotating the axis by -angle radians.
Inputs
- axis
- Vector
[x, y, z]
or[x; y; z]
describing the axis of rotation.- angle
- Rotation angle in radians. The positive direction is determined by the right-hand rule applied to axis. If angle is a real-valued array, a quaternion array q of the same size is returned.
Outputs
- q
- Unit quaternion describing the rotation. If angle is an array, q(i,j) corresponds to the rotation angle angle(i,j).
Example
octave:1> axis = [0, 0, 1]; octave:2> angle = pi/4; octave:3> q = rot2q (axis, angle) q = 0.9239 + 0i + 0j + 0.3827k octave:4> v = quaternion (1, 1, 0) v = 0 + 1i + 1j + 0k octave:5> vr = q * v * conj (q) vr = 0 + 0i + 1.414j + 0k octave:6>
Package: quaternion