- The Structure
- Members
- Arithmetic
- BrQuatMul()
- BrQuatInvert()
- BrQuatSlerp()
- Conversion
- BrQuatToEuler()
- BrQuatToMatrix34()
- BrQuatToMatrix4()
- Copy/Assign
- Access & Maintenance
- BrQuatNormalise()
- Initialisation

** br_quat**

The x, y and z components of the quaternion hold the elements of this vector scaled to a length equal to the sine of half the angle of rotation. The w component holds the cosine of half the angle. The magnitude of a unit quaternion is of course 1 (w2+x2+y2+z2=1).

The quaternion is written thus:

NB Do not confuse the quaternion with 3D vectors or homogenous co-ordinates, i.e. `br_quat`

*311*` and `

`br_vector4`

*365*` have no relationship.`

`typedef`

`quat.h `

for precise declaration and ordering)
**br_scalar w Real component**

**br_scalar x `i' component (vector, x axis component)**

**br_scalar y `j' component (vector, y axis component)**

**br_scalar z `k' component (vector, z axis component)**

`BrEulerToQuat()`

, `BrMatrix34ToQuat()`

, `BrMatrix4ToQuat()`

.

`br_transform`

.`br_scalar w`

`br_scalar x`

`br_scalar y`

`br_scalar z`

**BrQuatMul()**

Declaration:

**br_quat* BrQuatMul(br_quat* q, const br_quat* l, const br_quat* r)**

Arguments:

**br_quat * q**

A pointer to the destination quaternion (may be same as either source).

**const br_quat * l**

A pointer to the left hand source quaternion.

**const br_quat * r**

A pointer to the right hand source quaternion.

Effects: The resultant quaternion is computed as follows:

Result:

**br_quat ***

The destination quaternion pointer is returned as supplied for convenience.

Remarks: Quaternion multiplication has the effect of concatenating the individual transformations that each represents. It is not commutative.

**BrQuatInvert()**

Declaration:

**br_quat* BrQuatInvert(br_quat* q, const br_quat* qq)**

Arguments:

**br_quat * q**

A pointer to the destination quaternion (can be same as source).

**const br_quat * qq**

A pointer to the source quaternion.

Effects: The resultant quaternion is computed as follows:

Result:

**br_quat ***

The destination quaternion pointer is returned as supplied for convenience.

**BrQuatSlerp()**

Declaration:

**br_quat* BrQuatSlerp(br_quat* q, const br_quat* l, const br_quat* r, br_scalar t, br_int_16 spins)**

Arguments:

**br_quat * q**

A pointer to the destination quaternion (can be same as either source).

**const br_quat * l**

A pointer to the starting quaternion (equivalent to result with t=0).

**const br_quat * l**

A pointer to the finishing quaternion (equivalent to result with t=1).

**br_scalar t**

Interpolation parameter in the range [0,1].

**br_int_16**

Number of extra spins in the interpolated path.

A special value of zero causes interpolation along the shortest path.

A special value of -1 causes interpolation along the longest path.

Effects: Computes the quaternion between

`l `

and `r `

corresponding to position `t `

along the interpolated path between them.Result:

**br_quat ***

The destination quaternion pointer is returned as supplied for convenience.

`BrEulerToQuat()`

, `BrMatrix34ToQuat()`

, `BrMatrix4ToQuat()`

.

`BrQuatToEuler()`

, `BrQuatToMatrix34()`

, and `BrQuatToMatrix4()`

` `

as described below.
Also see `BrTransformToTransform()`

*343*`.`

**BrQuatToEuler()**

Declaration:

**br_euler* BrQuatToEuler(br_euler* euler, const br_quat* q)**

Arguments:

**br_euler * euler**

A pointer to the destination Euler angle set to receive the conversion.

**const br_quat * q**

A pointer to the source unit quaternion.

Result:

**br_euler ***

Returns `euler `

for convenience.

**BrQuatToMatrix34()**

Declaration:

**br_matrix34* BrQuatToMatrix34(br_matrix34* mat, const br_quat* q)**

Arguments:

**br_matrix34 * mat**

A pointer to the destination matrix to receive the conversion.

**const br_quat * q**

A pointer to the source unit quaternion.

Result:

**br_matrix34 ***

Returns `mat `

for convenience.

Remarks: The resulting matrix at

`mat `

is equivalent to the following:

**BrQuatToMatrix4()**

Declaration:

**br_matrix4* BrQuatToMatrix4(br_matrix4* mat, const br_quat* q)**

Arguments:

**br_matrix4 * mat**

A pointer to the destination matrix to receive the conversion.

**const br_quat * q**

A pointer to the source unit quaternion.

Result:

**br_matrix4 ***

Returns `mat `

for convenience.

See Also:

`BrQuatToMatrix34()`

.

**BrQuatNormalise()**

Declaration:

**br_quat* BrQuatNormalise(br_quat* q, const br_quat* qq)**

Arguments:

**br_quat * q**

A pointer to the destination quaternion (may be same as source).

**const br_quat * qq**

A pointer to the source quaternion.

Effects: The destination is each element of the source divided by its magnitude.

Remarks: BRender assumes that only unit quaternions are used, and due to this assumption being embodied in certain calculations, if non-unit quaternions are used it is likely that unwanted side effects such as scaling will be introduced. This function ensures that the quaternion is a unit one, and is intended to be applied to unit quaternions that have resulted from a large number of intermediate calculations and may have drifted (due to precision limitations) from unit magnitude.

BR_QUAT(x,y,z,w)Macro expands to

`{`

`BR_SCALAR`

`(x),`

`BR_SCALAR`

`(y),`

`BR_SCALAR`

`(z),`

`BR_SCALAR`

`(w)}`

.

All other initialisation should be member-wise or by using structure assignment.

Generated with CERN WebMaker