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 ([float, float, float] | Vector) – XYZ coordinates of the rotation axis vector.

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

Returns

[float, float, float, float] – 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