### Datatype quaternion

Quaternion numbers consist of four (!) floating point numbers: The first number is called “real part”, the second one “imaginary part” (or short: “i”), the third one “j”-part, the last one “k”-part.
Writing down a quaternion number is done by surrounding the four real numbers by parenthesis, separating them either by comma or by slash.

Examples

`  a = (1,2,3,4); // surrounded by brackets, separated by comma  a = (1.2/-1.3/2.2/-2.1); // surrounded by brackets, separated by /  `

Quaternion numbers are stored internally as four floating point numbers which use the 80 bit FPU format (internal coprocessor format), with 14 bit exponent and 64 bit mantissa. So each component of a quaternion number has the same precision as a real number.
Future versions of ChaosPro will perhaps allow you to use double or float for the four floating point numbers.

Converting to/from quaternion numbers

Quaternion numbers are converted automatically to other datatypes if necessary and allowed.

Converting to:

• bool: only real part of quaternion number is relevant. If real part of quaternion number is 0, then the bool will be false, otherwise true.
• int: real part of quaternion number gets rounded towards zero.
• real: real part of quaternion number will be taken.
• complex: real and imaginary part of complex number get the real and imaginary part of the quaternion number.

Converting from:

• bool: false gets converted to (0,0,0,0), true gets converted to (1,0,0,0).
• int: real part of quaternion number gets this value, all other parts are set to 0.
• real: real part of quaternion number gets this value, all other parts are set to 0.
• quaternion: real and imaginary part of quaternion number get the real and imaginary part of the complex number, “j” and “k” part of quaternion number will be 0..