Attention

You are viewing PyUnity docs under the develop branch. As such, they are only applicable if you installed from source. Go to https://docs.pyunity.x10.bz/en/latest/ for the most recent release.

# pyunity.values.quaternion module¶

Class to represent a rotation in 3D space.

class pyunity.values.quaternion.Quaternion[source]

Bases:

Class to represent a unit quaternion, also known as a versor.

Parameters
• w () – Real value of Quaternion

• x () – x coordinate of Quaternion

• y () – y coordinate of Quaternion

• z () – z coordinate of Quaternion

absDiff(other)[source]
copy()[source]

Deep copy of the Quaternion.

Returns

A deep copy

Return type

normalized()[source]

A normalized Quaternion, for rotations. If the length is 0, then the identity quaternion is returned.

Returns

A unit quaternion

Return type

property conjugate

The conjugate of a unit quaternion

RotateVector(vector)[source]

Rotate a vector by the quaternion

static FromAxis(angle, a)[source]

Create a quaternion from an angle and an axis.

Parameters
• angle () – Angle to rotate

• a () – Axis to rotate about

static Between(v1, v2)[source]
static FromDir(v)[source]
property angleAxisPair

Gets the angle and axis pair. Tuple of form (angle, axis).

static Euler(vector)[source]

Create a quaternion using Euler rotations.

Parameters

vector () – Euler rotations

Returns

Generated quaternion

Return type

property eulerAngles

Gets the Euler angles of the quaternion

static identity()[source]

Identity quaternion representing no rotation

class pyunity.values.quaternion.QuaternionDiff[source]

Bases: