1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*!
Mint - Math interoperability standard types.

Defines basic math types useful for computer graphics via the built-in Rust types.
Designed to serve as an interoperability standard between libraries
that do not necessarily depend on `mint` directly.
*/
#![deny(missing_docs)]

/// Vector in 2D space.
pub type Vector2<T> = [T; 2];
/// Vector in 3D space.
pub type Vector3<T> = [T; 3];
/// Vector in 4D space.
/// Useful as a homogeneous 3D vector representation.
pub type Vector4<T> = [T; 4];

/// Euler rotation angles in 3D space.
pub type EulerAngles<T> = (T, T, T);
/// Standard quaternion represented by the scalar and vector parts.
/// Useful for representing rotation in 3D space.
pub type Quaternion<T> = (T, Vector3<T>);
/// Dual quaternion.
/// Useful for representing both translation and rotation,
/// because of better interpolation quality.
pub type DualQuaternion<T> = (Quaternion<T>, Quaternion<T>);

/// 2x2 matrix.
pub type Matrix2<T> = [[T; 2]; 2];
/// 2x3 matrix.
/// Useful for combinging rotation, scale, and translation in 2D space,
/// when stored as column-major.
pub type Matrix2x3<T> = [[T; 2]; 3];
/// 3x2 matrix.
/// Useful for combinging rotation, scale, and translation in 2D space,
/// when stored as row-major.
pub type Matrix3x2<T> = [[T; 3]; 2];
/// 3x3 matrix.
pub type Matrix3<T> = [[T; 3]; 3];
/// 3x4 matrix.
/// Useful for combinging rotation, scale, and translation in 3D space,
/// when stored as column major.
pub type Matrix3x4<T> = [[T; 3]; 4];
/// 4x3 matrix.
/// Useful for combinging rotation, scale, and translation in 3D space,
/// when stored as row major.
pub type Matrix4x3<T> = [[T; 4]; 3];
/// 4x4 matrix.
pub type Matrix4<T> = [[T; 4]; 4];

/// A 3D transform represented by separate rotation quaternion,
/// uniform scale, and a position vector.
pub type QuatScalePos<T> = (Quaternion<T>, T, Vector3<T>);

/// A 3D transform represented by separate euler angles for rotation,
/// uniform scale, and a position vector.
pub type EulerScalePos<T> = (EulerAngles<T>, T, Vector3<T>);