Quaternion#
Added in version 1.0.
- class Quaternion(*args, **kwargs)#
A quaternion.
The contents of the Quaternion
structure are private
and should never be accessed directly.
Constructors#
- class Quaternion
- classmethod alloc() Quaternion #
Allocates a new
Quaternion
.The contents of the returned value are undefined.
Added in version 1.0.
Methods#
- class Quaternion
- add(b: Quaternion) Quaternion #
Adds two
Quaternion
a
andb
.Added in version 1.10.
- Parameters:
b – a
Quaternion
- dot(b: Quaternion) float #
Computes the dot product of two
Quaternion
.Added in version 1.0.
- Parameters:
b – a
Quaternion
- equal(b: Quaternion) bool #
Checks whether the given quaternions are equal.
Added in version 1.0.
- Parameters:
b – a
Quaternion
- init(x: float, y: float, z: float, w: float) Quaternion #
Initializes a
Quaternion
using the given four values.Added in version 1.0.
- Parameters:
x – the first component of the quaternion
y – the second component of the quaternion
z – the third component of the quaternion
w – the fourth component of the quaternion
- init_from_angle_vec3(angle: float, axis: Vec3) Quaternion #
Initializes a
Quaternion
using anangle
on a specificaxis
.Added in version 1.0.
- Parameters:
angle – the rotation on a given axis, in degrees
axis – the axis of rotation, expressed as a vector
- init_from_angles(deg_x: float, deg_y: float, deg_z: float) Quaternion #
Initializes a
Quaternion
using the values of the Euler angles on each axis.See also:
init_from_euler()
Added in version 1.0.
- Parameters:
deg_x – rotation angle on the X axis (yaw), in degrees
deg_y – rotation angle on the Y axis (pitch), in degrees
deg_z – rotation angle on the Z axis (roll), in degrees
- init_from_euler(e: Euler) Quaternion #
Initializes a
Quaternion
using the givenEuler
.Added in version 1.2.
- Parameters:
e – a
Euler
- init_from_matrix(m: Matrix) Quaternion #
Initializes a
Quaternion
using the rotation components of a transformation matrix.Added in version 1.0.
- Parameters:
m – a
Matrix
- init_from_quaternion(src: Quaternion) Quaternion #
Initializes a
Quaternion
with the values fromsrc
.Added in version 1.0.
- Parameters:
src – a
Quaternion
- init_from_radians(rad_x: float, rad_y: float, rad_z: float) Quaternion #
Initializes a
Quaternion
using the values of the Euler angles on each axis.See also:
init_from_euler()
Added in version 1.0.
- Parameters:
rad_x – rotation angle on the X axis (yaw), in radians
rad_y – rotation angle on the Y axis (pitch), in radians
rad_z – rotation angle on the Z axis (roll), in radians
- init_from_vec4(src: Vec4) Quaternion #
Initializes a
Quaternion
with the values fromsrc
.Added in version 1.0.
- Parameters:
src – a
Vec4
- init_identity() Quaternion #
Initializes a
Quaternion
using the identity transformation.Added in version 1.0.
- invert() Quaternion #
Inverts a
Quaternion
, and returns the conjugate quaternion ofq
.Added in version 1.0.
- multiply(b: Quaternion) Quaternion #
Multiplies two
Quaternion
a
andb
.Added in version 1.10.
- Parameters:
b – a
Quaternion
- normalize() Quaternion #
Normalizes a
Quaternion
.Added in version 1.0.
- scale(factor: float) Quaternion #
Scales all the elements of a
Quaternion
q
using the given scalar factor.Added in version 1.10.
- Parameters:
factor – a scaling factor
- slerp(b: Quaternion, factor: float) Quaternion #
Interpolates between the two given quaternions using a spherical linear interpolation, or SLERP, using the given interpolation
factor
.Added in version 1.0.
- Parameters:
b – a
Quaternion
factor – the linear interpolation factor
- to_angle_vec3() Tuple[float, Vec3] #
Converts a quaternion into an
angle
,axis
pair.Added in version 1.0.
- to_angles() Tuple[float, float, float] #
Converts a
Quaternion
to its corresponding rotations on the Euler angles on each axis.Added in version 1.2.
- to_matrix() Matrix #
Converts a quaternion into a transformation matrix expressing the rotation defined by the
Quaternion
.Added in version 1.0.
- to_radians() Tuple[float, float, float] #
Converts a
Quaternion
to its corresponding rotations on the Euler angles on each axis.Added in version 1.2.
- to_vec4() Vec4 #
Copies the components of a
Quaternion
into aVec4
.Added in version 1.0.