csgrs/
float_types.rs

1// Re-export parry and rapier for the apropriate float size
2#[cfg(feature = "f64")]
3pub use parry3d_f64 as parry3d;
4#[cfg(feature = "f64")]
5pub use rapier3d_f64 as rapier3d;
6
7#[cfg(feature = "f32")]
8pub use parry3d;
9#[cfg(feature = "f32")]
10pub use rapier3d;
11
12// Our Real scalar type:
13#[cfg(feature = "f32")]
14pub type Real = f32;
15#[cfg(feature = "f64")]
16pub type Real = f64;
17
18/// A small epsilon for geometric comparisons, adjusted per precision.
19#[cfg(feature = "f32")]
20pub const EPSILON: Real = 1e-5;
21#[cfg(feature = "f64")]
22pub const EPSILON: Real = 1e-12;
23
24// Pi
25#[cfg(feature = "f32")]
26pub const PI: Real = core::f32::consts::PI;
27#[cfg(feature = "f64")]
28pub const PI: Real = core::f64::consts::PI;
29
30// Frac Pi 2
31#[cfg(feature = "f32")]
32pub const FRAC_PI_2: Real = core::f32::consts::FRAC_PI_2;
33#[cfg(feature = "f64")]
34pub const FRAC_PI_2: Real = core::f64::consts::FRAC_PI_2;
35
36// Tau
37#[cfg(feature = "f32")]
38pub const TAU: Real = core::f32::consts::TAU;
39#[cfg(feature = "f64")]
40pub const TAU: Real = core::f64::consts::TAU;
41
42// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43// Unit conversion
44// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45pub const INCH: Real = 25.4;
46pub const FOOT: Real =  25.4 * 12.0;
47pub const YARD: Real = 25.4 * 36.0;
48pub const MM: Real = 1.0;
49pub const CM: Real = 10.0;
50pub const METER: Real = 1000.0;