1.9 <GrapheneQuaternion>

Structure: <GrapheneQuaternion>

A quaternion.

The contents of the <GrapheneQuaternion> structure are private and should never be accessed directly.

Procedures

Method: quaternion:add! self b res ⇒ res
Method: add! self b res ⇒ res

Adds two <GrapheneQuaternion> self and b.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

b

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

res

Passed, filled in, and returned: a <GrapheneQuaternion>.

the result of the operation

Procedure: quaternion:alloc ⇒ %return

Allocates a new <GrapheneQuaternion>.

The contents of the returned value are undefined.

%return

Returned: a <GrapheneQuaternion>.

the newly allocated <GrapheneQuaternion>

Method: quaternion:dot self b ⇒ %return
Method: dot self b ⇒ %return

Computes the dot product of two <GrapheneQuaternion>.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

b

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

%return

Returned: a real number.

the value of the dot products

Method: quaternion:equal? self b ⇒ %return
Method: equal? self b ⇒ %return

Checks whether the given quaternions are equal.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

b

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

%return

Returned: a boolean.

true if the quaternions are equal

Method: quaternion:free self
Method: free self

Releases the resources allocated by quaternion:alloc.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

Method: quaternion:init self x y z w ⇒ %return
Method: init self x y z w ⇒ %return

Initializes a <GrapheneQuaternion> using the given four values.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

x

Passed: a real number.

the first component of the quaternion

y

Passed: a real number.

the second component of the quaternion

z

Passed: a real number.

the third component of the quaternion

w

Passed: a real number.

the fourth component of the quaternion

%return

Returned: a <GrapheneQuaternion>.

the initialized quaternion

Method: quaternion:init-from-angle-vec3 self angle axis ⇒ %return
Method: init-from-angle-vec3 self angle axis ⇒ %return

Initializes a <GrapheneQuaternion> using an angle on a specific axis.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

angle

Passed: a real number.

the rotation on a given axis, in degrees

axis

Passed: a <GrapheneVec3>.

the axis of rotation, expressed as a vector

%return

Returned: a <GrapheneQuaternion>.

the initialized quaternion

Method: quaternion:init-from-angles self deg-x deg-y deg-z ⇒ %return
Method: init-from-angles self deg-x deg-y deg-z ⇒ %return

Initializes a <GrapheneQuaternion> using the values of the Euler angles on each axis.

See also: quaternion:init-from-euler

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

deg-x

Passed: a real number.

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

deg-y

Passed: a real number.

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

deg-z

Passed: a real number.

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

%return

Returned: a <GrapheneQuaternion>.

the initialized quaternion

Method: quaternion:init-from-euler self e ⇒ %return
Method: init-from-euler self e ⇒ %return

Initializes a <GrapheneQuaternion> using the given <GrapheneEuler>.

self

Passed: a <GrapheneQuaternion>.

the <GrapheneQuaternion> to initialize

e

Passed: a <GrapheneEuler>.

a <GrapheneEuler>

%return

Returned: a <GrapheneQuaternion>.

the initialized <GrapheneQuaternion>

Method: quaternion:init-from-matrix self m ⇒ %return
Method: init-from-matrix self m ⇒ %return

Initializes a <GrapheneQuaternion> using the rotation components of a transformation matrix.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

m

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a <GrapheneQuaternion>.

the initialized quaternion

Method: quaternion:init-from-quaternion self src ⇒ %return
Method: init-from-quaternion self src ⇒ %return

Initializes a <GrapheneQuaternion> with the values from src.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

src

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

%return

Returned: a <GrapheneQuaternion>.

the initialized quaternion

Method: quaternion:init-from-radians self rad-x rad-y rad-z ⇒ %return
Method: init-from-radians self rad-x rad-y rad-z ⇒ %return

Initializes a <GrapheneQuaternion> using the values of the Euler angles on each axis.

See also: quaternion:init-from-euler

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

rad-x

Passed: a real number.

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

rad-y

Passed: a real number.

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

rad-z

Passed: a real number.

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

%return

Returned: a <GrapheneQuaternion>.

the initialized quaternion

Method: quaternion:init-from-vec4 self src ⇒ %return
Method: init-from-vec4 self src ⇒ %return

Initializes a <GrapheneQuaternion> with the values from src.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

src

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

%return

Returned: a <GrapheneQuaternion>.

the initialized quaternion

Method: quaternion:init-identity self ⇒ %return
Method: init-identity self ⇒ %return

Initializes a <GrapheneQuaternion> using the identity transformation.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

%return

Returned: a <GrapheneQuaternion>.

the initialized quaternion

Method: quaternion:invert! self res ⇒ res
Method: invert! self res ⇒ res

Inverts a <GrapheneQuaternion>, and returns the conjugate quaternion of self.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

res

Passed, filled in, and returned: a <GrapheneQuaternion>.

return location for the inverted quaternion

Method: quaternion:multiply! self b res ⇒ res
Method: multiply! self b res ⇒ res

Multiplies two <GrapheneQuaternion> self and b.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

b

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

res

Passed, filled in, and returned: a <GrapheneQuaternion>.

the result of the operation

Method: quaternion:normalize! self res ⇒ res
Method: normalize! self res ⇒ res

Normalizes a <GrapheneQuaternion>.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

res

Passed, filled in, and returned: a <GrapheneQuaternion>.

return location for the normalized quaternion

Method: quaternion:scale! self factor res ⇒ res
Method: scale! self factor res ⇒ res

Scales all the elements of a <GrapheneQuaternion> self using the given scalar factor.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

factor

Passed: a real number.

a scaling factor

res

Passed, filled in, and returned: a <GrapheneQuaternion>.

the result of the operation

Method: quaternion:slerp! self b factor res ⇒ res
Method: slerp! self b factor res ⇒ res

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

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

b

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

factor

Passed: a real number.

the linear interpolation factor

res

Passed, filled in, and returned: a <GrapheneQuaternion>.

return location for the interpolated quaternion

Method: quaternion:to-angle-vec3! self axis ⇒ angle axis
Method: to-angle-vec3! self axis ⇒ angle axis

Converts a quaternion into an angle, axis pair.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

axis

Passed, filled in, and returned: a <GrapheneVec3>.

return location for the rotation axis

angle

Returned: a real number.

return location for the angle, in degrees

Method: quaternion:to-angles self ⇒ deg-x deg-y deg-z
Method: to-angles self ⇒ deg-x deg-y deg-z

Converts a <GrapheneQuaternion> to its corresponding rotations on the Euler angles on each axis.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

deg-x

Returned: a real number.

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

deg-y

Returned: a real number.

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

deg-z

Returned: a real number.

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

Method: quaternion:to-matrix! self m ⇒ m
Method: to-matrix! self m ⇒ m

Converts a quaternion into a transformation matrix expressing the rotation defined by the <GrapheneQuaternion>.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

m

Passed, filled in, and returned: a <GrapheneMatrix>.

a <GrapheneMatrix>

Method: quaternion:to-radians self ⇒ rad-x rad-y rad-z
Method: to-radians self ⇒ rad-x rad-y rad-z

Converts a <GrapheneQuaternion> to its corresponding rotations on the Euler angles on each axis.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

rad-x

Returned: a real number.

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

rad-y

Returned: a real number.

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

rad-z

Returned: a real number.

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

Method: quaternion:to-vec4! self res ⇒ res
Method: to-vec4! self res ⇒ res

Copies the components of a <GrapheneQuaternion> into a <GrapheneVec4>.

self

Passed: a <GrapheneQuaternion>.

a <GrapheneQuaternion>

res

Passed, filled in, and returned: a <GrapheneVec4>.

return location for a <GrapheneVec4>