Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK Go to the latest version
Important

IBM Quantum Platform is moving and this version will be sunset on July 1. To get started on the new platform, read the migration guide.

Quaternion

class Quaternion(data)

GitHub

Bases: object

A class representing a Quaternion.


Methods

from_axis_rotation

classmethod Quaternion.from_axis_rotation(angle, axis)

Return quaternion for rotation about given axis.

Parameters

  • angle (float) – Angle in radians.
  • axis (str) – Axis for rotation

Returns

Quaternion for axis rotation.

Return type

Quaternion

Raises

ValueError – Invalid input axis.

from_euler

classmethod Quaternion.from_euler(angles, order='yzy')

Generate a quaternion from a set of Euler angles.

Parameters

  • angles (array_like) – Array of Euler angles.
  • order (str) – Order of Euler rotations. ‘yzy’ is default.

Returns

Quaternion representation of Euler rotation.

Return type

Quaternion

norm

Quaternion.norm()

Norm of quaternion.

normalize

Quaternion.normalize(inplace=False)

Normalizes a Quaternion to unit length so that it represents a valid rotation.

Parameters

inplace (bool) – Do an inplace normalization.

Returns

Normalized quaternion.

Return type

Quaternion

to_matrix

Quaternion.to_matrix()

Converts a unit-length quaternion to a rotation matrix.

Returns

Rotation matrix.

Return type

ndarray

to_zyz

Quaternion.to_zyz()

Converts a unit-length quaternion to a sequence of ZYZ Euler angles.

Returns

Array of Euler angles.

Return type

ndarray

Was this page helpful?
Report a bug or request content on GitHub.