tri_mesh/
math.rs

1//!
2//! Linear algebra types for vector calculations. Basically re-export the [cgmath](https://crates.io/crates/cgmath) library.
3//!
4
5use cgmath;
6pub use cgmath::prelude::*;
7pub use cgmath::{Deg, Matrix3, Matrix4, Rad, Vector3, Vector4};
8
9/// Vector with three elements.
10pub type Vec3 = Vector3<f64>;
11/// Vector with four elements.
12pub type Vec4 = Vector4<f64>;
13
14/// 3x3 matrix.
15pub type Mat3 = Matrix3<f64>;
16/// 4x4 matrix.
17pub type Mat4 = Matrix4<f64>;
18
19/// Degrees
20pub type Degrees = Deg<f64>;
21/// Radians
22pub type Radians = Rad<f64>;
23
24/// Constructs a [Vec3]
25pub const fn vec3(x: f64, y: f64, z: f64) -> Vec3 {
26    Vector3::new(x, y, z)
27}
28
29/// Constructs a [Vec4]
30pub const fn vec4(x: f64, y: f64, z: f64, w: f64) -> Vec4 {
31    Vector4::new(x, y, z, w)
32}
33
34/// Constructs a [Degrees]
35pub const fn degrees(v: f64) -> Degrees {
36    Deg(v)
37}
38/// Constructs a [Radians]
39pub const fn radians(v: f64) -> Radians {
40    Rad(v)
41}