quaternion_from_axis_angle

compas.geometry.quaternion_from_axis_angle(axis, angle)[source]

Returns a quaternion describing a rotation around the given axis by the given angle.

Parameters
  • axis (list) – Coordinates [x, y, z] of the rotation axis vector.

  • angle (float) – Angle of rotation in radians.

Returns

list – Quaternion as a list of four real values [qw, qx, qy, qz].

Examples

>>> axis =  [1.0, 0.0, 0.0]
>>> angle = math.pi/2
>>> q = quaternion_from_axis_angle(axis, angle)
>>> allclose(q, [math.sqrt(2)/2, math.sqrt(2)/2, 0, 0])
True