[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.4 Quaternions

Class: <quatf>

Quaternions. Internally quaternions are represented as just an array of four floats; the first three are the vector component and the last is the scalar component.

Inherits <sequence> and <collection>. When viewed as sequence, it is just like a vector of four floats.

Function: quatf? obj

Returns true iff obj is a quaternion.

Reader syntax: #,(quatf x y z w)

External representation of quaternion xi+yj+zk+w.

Function: make-quatf &optional axis (angle 0)

Returns a new unit quaternion that represents a rotation around vector axis by angle radians. Axis can be a vector4f, a point4f or a f32vector (only first three component is used). Axis must be a unit vector; if axis is anormalized, the result is undefined.

If both axis and angle is omitted, #,(quatf 0 0 0 1) is returned.

Function: quatf x y z w

Returns a new quaternion whose elements are initialized by x, y, z, w.

Function: list->quatf l
Function: quatf->list q

Converts between a list of four real numbers and a quaternion.

Function: f32vector->quatf x &optional start

Returns a new quaternion whose elements are initialized by the first four elements of f32vector x. If start is given, the initial value is taken starting from start-th index in x.

Function: quatf->f32vector q

Returns a new f32vector whose contents is the same as a quaternion q.

Function: quatf-copy q

Returns a fresh copy of a quaternion q.

Function: quatf-copy! dstq srcq

Copies contents of a quaternion srcq to a quaternion dstq.

Function: rotation->quatf! quat axis angle

Sets a quaternion quat so that it represents a rotation around a unit vector axis by angle angle radians. Axis can be a vector4f, a point4f or a f32vector (only first three component is used).

Function: vectors->quatf v w
Function: vectors->quatf! q v w

Given two unit vectors v and w, calculates and returns a quaternion that represents a rotation from v to w. The destructive version vectors->quatf! modifies q.

Function: axes->quatf v1 v2 w1 w2
Function: axes->quatf! q v1 v2 w1 w2

The arguments must be all unit vectors, v1 and v2 must be perpendicular, and also w1 and w2 must be perpendicular.

Calculates and returns a quaternion that represents a rotation which transforms v1 to w1, and v2 to w2, respectively. The destructive version stores the result into q.

Function: quatf-add p q
Function: quatf-add! p q
Function: quatf-sub p q
Function: quatf-sub! p q

Addition and subtraction of quaternions. The destructive version modifies the first argument.

Function: quatf-scale q s
Function: quatf-scale! q s

Multiplies a quaternion q by a scalar value s. The destructive version modifies q.

Function: quatf-mul p q
Function: quatf-mul! p q

Multiply two quaternions p and q. The destructive version modifies p as well.

Function: quatf-conjugate p
Function: quatf-conjugate! q p

Returns a conjugate of a quaternion p. The destructive version modifies q as well.

Function: quatf-transform q p

Transforms a vector or a point p by quaternion q, that is, returns qpq*, where q* is a conjugate of q.

This procedure assumes q is normalized.

P can be a vector4f, a point4f or a f32vector (only first three elements are used). Returns the same type of object as p.

Function: quatf-norm q

Returns norm of q.

Function: quatf-normalize q
Function: quatf-normalize! q

Returns normalized quaternion of q. The destructive version modifies q.

Function: quatf->matrix4f q
Function: quatf->matrix4f! m q

Returns a matrix that represents a rotation specified by a unit quaternion q. The behavior is undefined if q is not normalized. The destructive version modifies m.

Function: matrix4f->quatf m
Function: matrix4f->quatf! q m

Extracts the rotation component of a matrix m and returns a quaterion that represents the rotation. Matrix4f->quatf! also uses q as the storage to store the result.

Function: quatf-slerp p q t
Function: quatf-slerp! r p q t

Returns a quaternion that interpolates between two unit quaternions p and q, by a scalar value t. The destructive version modifies t.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by Shiro Kawai on June, 7 2008 using texi2html 1.78.