Graphene.Quaternion

Fields

Name

Type

Access

Description

w

float

r

x

float

r

y

float

r

z

float

r

Methods

class

alloc ()

add (b)

dot (b)

equal (b)

free ()

init (x, y, z, w)

init_from_angle_vec3 (angle, axis)

init_from_angles (deg_x, deg_y, deg_z)

init_from_euler (e)

init_from_matrix (m)

init_from_quaternion (src)

init_from_radians (rad_x, rad_y, rad_z)

init_from_vec4 (src)

init_identity ()

invert ()

multiply (b)

normalize ()

scale (factor)

slerp (b, factor)

to_angle_vec3 ()

to_angles ()

to_matrix ()

to_radians ()

to_vec4 ()

Details

class Graphene.Quaternion

A quaternion.

The contents of the Graphene.Quaternion structure are private and should never be accessed directly.

New in version 1.0.

classmethod alloc()
Returns:

the newly allocated Graphene.Quaternion

Return type:

Graphene.Quaternion

Allocates a new Graphene.Quaternion.

The contents of the returned value are undefined.

New in version 1.0.

add(b)
Parameters:

b (Graphene.Quaternion) – a Graphene.Quaternion

Returns:

the result of the operation

Return type:

res: Graphene.Quaternion

Adds two Graphene.Quaternion self and b.

New in version 1.10.

dot(b)
Parameters:

b (Graphene.Quaternion) – a Graphene.Quaternion

Returns:

the value of the dot products

Return type:

float

Computes the dot product of two Graphene.Quaternion.

New in version 1.0.

equal(b)
Parameters:

b (Graphene.Quaternion) – a Graphene.Quaternion

Returns:

true if the quaternions are equal

Return type:

bool

Checks whether the given quaternions are equal.

New in version 1.0.

free()

Releases the resources allocated by Graphene.Quaternion.alloc().

New in version 1.0.

init(x, y, z, w)
Parameters:
  • x (float) – the first component of the quaternion

  • y (float) – the second component of the quaternion

  • z (float) – the third component of the quaternion

  • w (float) – the fourth component of the quaternion

Returns:

the initialized quaternion

Return type:

Graphene.Quaternion

Initializes a Graphene.Quaternion using the given four values.

New in version 1.0.

init_from_angle_vec3(angle, axis)
Parameters:
  • angle (float) – the rotation on a given axis, in degrees

  • axis (Graphene.Vec3) – the axis of rotation, expressed as a vector

Returns:

the initialized quaternion

Return type:

Graphene.Quaternion

Initializes a Graphene.Quaternion using an angle on a specific axis.

New in version 1.0.

init_from_angles(deg_x, deg_y, deg_z)
Parameters:
  • deg_x (float) – rotation angle on the X axis (yaw), in degrees

  • deg_y (float) – rotation angle on the Y axis (pitch), in degrees

  • deg_z (float) – rotation angle on the Z axis (roll), in degrees

Returns:

the initialized quaternion

Return type:

Graphene.Quaternion

Initializes a Graphene.Quaternion using the values of the Euler angles on each axis.

See also: Graphene.Quaternion.init_from_euler()

New in version 1.0.

init_from_euler(e)
Parameters:

e (Graphene.Euler) – a Graphene.Euler

Returns:

the initialized Graphene.Quaternion

Return type:

Graphene.Quaternion

Initializes a Graphene.Quaternion using the given Graphene.Euler.

New in version 1.2.

init_from_matrix(m)
Parameters:

m (Graphene.Matrix) – a Graphene.Matrix

Returns:

the initialized quaternion

Return type:

Graphene.Quaternion

Initializes a Graphene.Quaternion using the rotation components of a transformation matrix.

New in version 1.0.

init_from_quaternion(src)
Parameters:

src (Graphene.Quaternion) – a Graphene.Quaternion

Returns:

the initialized quaternion

Return type:

Graphene.Quaternion

Initializes a Graphene.Quaternion with the values from src.

New in version 1.0.

init_from_radians(rad_x, rad_y, rad_z)
Parameters:
  • rad_x (float) – rotation angle on the X axis (yaw), in radians

  • rad_y (float) – rotation angle on the Y axis (pitch), in radians

  • rad_z (float) – rotation angle on the Z axis (roll), in radians

Returns:

the initialized quaternion

Return type:

Graphene.Quaternion

Initializes a Graphene.Quaternion using the values of the Euler angles on each axis.

See also: Graphene.Quaternion.init_from_euler()

New in version 1.0.

init_from_vec4(src)
Parameters:

src (Graphene.Vec4) – a Graphene.Vec4

Returns:

the initialized quaternion

Return type:

Graphene.Quaternion

Initializes a Graphene.Quaternion with the values from src.

New in version 1.0.

init_identity()
Returns:

the initialized quaternion

Return type:

Graphene.Quaternion

Initializes a Graphene.Quaternion using the identity transformation.

New in version 1.0.

invert()
Returns:

return location for the inverted quaternion

Return type:

res: Graphene.Quaternion

Inverts a Graphene.Quaternion, and returns the conjugate quaternion of self.

New in version 1.0.

multiply(b)
Parameters:

b (Graphene.Quaternion) – a Graphene.Quaternion

Returns:

the result of the operation

Return type:

res: Graphene.Quaternion

Multiplies two Graphene.Quaternion self and b.

New in version 1.10.

normalize()
Returns:

return location for the normalized quaternion

Return type:

res: Graphene.Quaternion

Normalizes a Graphene.Quaternion.

New in version 1.0.

scale(factor)
Parameters:

factor (float) – a scaling factor

Returns:

the result of the operation

Return type:

res: Graphene.Quaternion

Scales all the elements of a Graphene.Quaternion self using the given scalar factor.

New in version 1.10.

slerp(b, factor)
Parameters:
Returns:

return location for the interpolated quaternion

Return type:

res: Graphene.Quaternion

Interpolates between the two given quaternions using a spherical linear interpolation, or SLERP, using the given interpolation factor.

New in version 1.0.

to_angle_vec3()
Returns:

angle:

return location for the angle, in degrees

axis:

return location for the rotation axis

Return type:

(angle: float, axis: Graphene.Vec3)

Converts a quaternion into an angle, axis pair.

New in version 1.0.

to_angles()
Returns:

deg_x:

return location for the rotation angle on the X axis (yaw), in degrees

deg_y:

return location for the rotation angle on the Y axis (pitch), in degrees

deg_z:

return location for the rotation angle on the Z axis (roll), in degrees

Return type:

(deg_x: float, deg_y: float, deg_z: float)

Converts a Graphene.Quaternion to its corresponding rotations on the Euler angles on each axis.

New in version 1.2.

to_matrix()
Returns:

a Graphene.Matrix

Return type:

m: Graphene.Matrix

Converts a quaternion into a transformation matrix expressing the rotation defined by the Graphene.Quaternion.

New in version 1.0.

to_radians()
Returns:

rad_x:

return location for the rotation angle on the X axis (yaw), in radians

rad_y:

return location for the rotation angle on the Y axis (pitch), in radians

rad_z:

return location for the rotation angle on the Z axis (roll), in radians

Return type:

(rad_x: float, rad_y: float, rad_z: float)

Converts a Graphene.Quaternion to its corresponding rotations on the Euler angles on each axis.

New in version 1.2.

to_vec4()
Returns:

return location for a Graphene.Vec4

Return type:

res: Graphene.Vec4

Copies the components of a Graphene.Quaternion into a Graphene.Vec4.

New in version 1.0.