# quat

## quaternions

### See course about the quaternions

.

A quaternion is a four-dimensional vector q=w,x,y,z which is the geometric interpretation of the rotation angle 2 * acos (w) around the axis x, y, z.
Quaternions are used to perform rotations in space preferably traditional product of 3 rotations around axes x, y and z have adverse effects (especially their interpolations).

## quat matrix

### quat matrix(m)

Returns the quaternion q matrix.
Examples:
`m=quat(0,0,0,0);edit(m)format(4);`
prints:
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
`m=matrix quat(.25*PI,0,0,1)edit(m)format(4);`
prints:
-1.000000 -1.570796 0.000000 0.000000
1.570796 -1.000000 0.000000 0.000000
0.000000 0.000000 1.000000 0.000000
0.000000 0.000000 0.000000 1.000000

## quat rota

### quat rota(a,x,y,z)

Returns the quaternion from rotation angle -PI<=a<=PI and axis (x,y,z).

## quat vol

### quat vol(id)

Returns the quaternion of volume id.

### quat vol(id)=w,x,y,z

Changes this quaternion.
Note:
We will:
rota matrix vol(id)=a=2*acos(w), and
module(x,y,z)=sin(a/2).