Skip to content

Commit 6e57b14

Browse files
committed
undo last commit, commit to branch instead
1 parent de0ba0e commit 6e57b14

File tree

3 files changed

+64
-759
lines changed

3 files changed

+64
-759
lines changed

src/float_types.rs

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

src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#![warn(clippy::missing_const_for_fn, clippy::approx_constant, clippy::all)]
3131

3232
pub mod errors;
33-
pub mod math_ndsp;
33+
pub mod float_types;
3434
pub mod io;
3535
pub mod mesh;
3636
pub mod nurbs;
@@ -51,5 +51,11 @@ pub mod wasm;
5151
))]
5252
compile_error!("Either 'delaunay' or 'earcut' feature must be specified, but not both");
5353

54+
#[cfg(any(
55+
all(feature = "f64", feature = "f32"),
56+
not(any(feature = "f64", feature = "f32"))
57+
))]
58+
compile_error!("Either 'f64' or 'f32' feature must be specified, but not both");
59+
5460
#[cfg(test)]
5561
mod tests;

0 commit comments

Comments
 (0)