Skip to content

Commit d57fec0

Browse files
committed
fix up some import errors
1 parent af16782 commit d57fec0

File tree

10 files changed

+30
-26
lines changed

10 files changed

+30
-26
lines changed

src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
type Real = f64;
2-
use nalgebra::Point3;
2+
use crate::math_ndsp::Point3;
33

44
/// All the possible validation issues we might encounter,
55
#[derive(Debug, Clone, PartialEq)]

src/io/dxf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<S: Clone + Debug + Send + Sync> Mesh<S> {
8181

8282
for i in 0..segments {
8383
let theta =
84-
2.0 * crate::float_types::PI * (i as Real) / (segments as Real);
84+
2.0 * crate::math_ndsp::consts::PI * (i as Real) / (segments as Real);
8585
let x = center.x as Real + radius * theta.cos();
8686
let y = center.y as Real + radius * theta.sin();
8787
let z = center.z as Real;

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
pub mod errors;
3333
pub mod math_ndsp;
34+
pub mod aabb;
3435
pub mod io;
3536
pub mod mesh;
3637
pub mod nurbs;

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type Real = f64;
88

99
use csgrs::mesh::plane::Plane;
1010
use csgrs::traits::CSG;
11-
use nalgebra::{Point3, Vector3};
11+
use crate::math_ndsp::{Point3, Vector3};
1212
use std::fs;
1313

1414
#[cfg(feature = "image")]

src/math_ndsp.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
44
use mixed_num::traits::*;
5+
use mixed_num::MixedAbs;
6+
type Real = f64;
57

68
pub mod consts {
79
// We keep the library on f64 for now (simple migration).
@@ -28,7 +30,7 @@ pub struct Vector3<T> {
2830
pub z: T,
2931
}
3032

31-
impl<T: MixedNum + MixedOps + Copy> Vector3<T> {
33+
impl<T: MixedNum + MixedOps + Copy + MixedAbs> Vector3<T> {
3234
#[inline]
3335
pub const fn new(x: T, y: T, z: T) -> Self { Self { x, y, z } }
3436

@@ -207,17 +209,17 @@ impl<T: MixedNum + MixedOps + Copy> Matrix3<T> {
207209
let det = self.det();
208210
if det.mixed_abs() <= eps() { return None; }
209211
let m = &self.m;
210-
let c00 = (m[1][1]*m[2][2] - m[1][2]*m[2][1]);
212+
let c00 = m[1][1]*m[2][2] - m[1][2]*m[2][1];
211213
let c01 = -(m[1][0]*m[2][2] - m[1][2]*m[2][0]);
212-
let c02 = (m[1][0]*m[2][1] - m[1][1]*m[2][0]);
214+
let c02 = m[1][0]*m[2][1] - m[1][1]*m[2][0];
213215

214216
let c10 = -(m[0][1]*m[2][2] - m[0][2]*m[2][1]);
215-
let c11 = (m[0][0]*m[2][2] - m[0][2]*m[2][0]);
217+
let c11 = m[0][0]*m[2][2] - m[0][2]*m[2][0];
216218
let c12 = -(m[0][0]*m[2][1] - m[0][1]*m[2][0]);
217219

218-
let c20 = (m[0][1]*m[1][2] - m[0][2]*m[1][1]);
220+
let c20 = m[0][1]*m[1][2] - m[0][2]*m[1][1];
219221
let c21 = -(m[0][0]*m[1][2] - m[0][2]*m[1][0]);
220-
let c22 = (m[0][0]*m[1][1] - m[0][1]*m[1][0]);
222+
let c22 = m[0][0]*m[1][1] - m[0][1]*m[1][0];
221223

222224
let adj_t = [
223225
[c00, c10, c20],
@@ -310,7 +312,7 @@ impl<T: MixedNum + MixedOps + Copy> Matrix3<T> {
310312
Vector3::z()
311313
};
312314
ortho = f.cross(ortho).normalize();
313-
return Self::rotation_axis_angle(ortho, (T::mixed_pi()));
315+
return Self::rotation_axis_angle(ortho, T::mixed_pi());
314316
}
315317
}
316318
// Rodrigues without trig: R = I + [v]_x + [v]_x² * ((1 - c)/|v|²)
@@ -559,7 +561,7 @@ impl Rotation3 {
559561
pub fn from_axis_angle(axis: &Vector3, angle: Real) -> Self {
560562
let mut k = *axis;
561563
let n2 = k.dot(&k);
562-
if n2 <= EPSILON * EPSILON {
564+
if n2 <= consts::EPSILON * consts::EPSILON {
563565
return Self::identity();
564566
}
565567
k /= n2.sqrt(); // normalize
@@ -591,7 +593,7 @@ impl Rotation3 {
591593
pub fn rotation_between(a: &Vector3, b: &Vector3) -> Option<Self> {
592594
let la = a.norm();
593595
let lb = b.norm();
594-
if la <= EPSILON || lb <= EPSILON {
596+
if la <= consts::EPSILON || lb <= consts::EPSILON {
595597
return None;
596598
}
597599
let u = *a / la;
@@ -601,7 +603,7 @@ impl Rotation3 {
601603
let axis = u.cross(&v);
602604
let s = axis.norm(); // |u × v| = sin(theta)
603605

604-
if s <= EPSILON {
606+
if s <= consts::EPSILON {
605607
// Collinear: either identity or 180° turn around any perpendicular axis.
606608
if c > 0.0 {
607609
return Some(Self::identity());

src/sketch/extrudes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ impl<S: Clone + Debug + Send + Sync> Sketch<S> {
824824
/// * returns - a `Mesh<S>` containing all side quads plus automatically triangulated caps (respecting any holes).
825825
pub fn sweep(&self, path: &[Point3<Real>]) -> Mesh<S> {
826826
use crate::mesh::{Mesh, polygon::Polygon, vertex::Vertex};
827-
use nalgebra::{Matrix4, Rotation3, Translation3};
827+
use crate::math_ndsp::{Matrix4, Rotation3, Translation3};
828828

829829
// sanity checks
830830
if path.len() < 2 || self.geometry.0.is_empty() {

src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::sketch::Sketch;
99
use crate::traits::CSG;
1010
use geo::{Area, Geometry, HasDimensions};
1111
use hashbrown::HashMap;
12-
use nalgebra::{Point3, Vector3};
12+
use crate::math_ndsp::{Point3, Vector3};
1313
type Real = f64;
1414

1515
// --------------------------------------------------------

src/toolpath/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
//! - Requires `csgrs` to be compiled with the `offset` feature for kerf/tool radius comp.
1616
1717
use core::fmt::Debug;
18-
use nalgebra::Point3;
18+
use crate::math_ndsp::Point3;
1919

20-
use crate::float_types::{EPSILON, Real};
20+
type Real = f64;
21+
use crate::math_ndsp::consts::{EPSILON};
2122
use crate::sketch::Sketch;
2223

2324
// ==========================

src/traits.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::float_types::parry3d::bounding_volume::Aabb;
1+
use crate::aabb::Aabb;
22
use crate::math_ndsp::consts::{EPSILON};
33
use crate::mesh::plane::Plane;
4-
use nalgebra::{Matrix3, Matrix4, Rotation3, Translation3, Vector3};
4+
use crate::math_ndsp::{Matrix3, Matrix4, Rotation3, Translation3, Vector3};
55
type Real = f64;
66

77
/// Boolean operations + transformations
@@ -179,11 +179,11 @@ pub trait CSG: Sized + Clone {
179179

180180
let angle = start_rad + t * sweep;
181181
let rot =
182-
nalgebra::Rotation3::from_axis_angle(&nalgebra::Vector3::z_axis(), angle)
182+
Rotation3::from_axis_angle(&Vector3::z_axis(), angle)
183183
.to_homogeneous();
184184

185185
// translate out to radius in x
186-
let trans = nalgebra::Translation3::new(radius, 0.0, 0.0).to_homogeneous();
186+
let trans = Translation3::new(radius, 0.0, 0.0).to_homogeneous();
187187
let mat = rot * trans;
188188
self.transform(&mat)
189189
})
@@ -209,7 +209,7 @@ pub trait CSG: Sized + Clone {
209209
(0..count)
210210
.map(|i| {
211211
let offset = step * (i as Real);
212-
let trans = nalgebra::Translation3::from(offset).to_homogeneous();
212+
let trans = Translation3::from(offset).to_homogeneous();
213213
self.transform(&trans)
214214
})
215215
.reduce(|acc, csg| acc.union(&csg))
@@ -222,14 +222,14 @@ pub trait CSG: Sized + Clone {
222222
if rows < 1 || cols < 1 {
223223
return self.clone();
224224
}
225-
let step_x = nalgebra::Vector3::new(dx, 0.0, 0.0);
226-
let step_y = nalgebra::Vector3::new(0.0, dy, 0.0);
225+
let step_x = Vector3::new(dx, 0.0, 0.0);
226+
let step_y = Vector3::new(0.0, dy, 0.0);
227227

228228
(0..rows)
229229
.flat_map(|r| {
230230
(0..cols).map(move |c| {
231231
let offset = step_x * (c as Real) + step_y * (r as Real);
232-
let trans = nalgebra::Translation3::from(offset).to_homogeneous();
232+
let trans = Translation3::from(offset).to_homogeneous();
233233
self.transform(&trans)
234234
})
235235
})

src/wasm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::sketch::Sketch;
66
use crate::traits::CSG;
77
use geo::{Geometry, GeometryCollection};
88
use js_sys::{Float64Array, Object, Reflect, Uint32Array};
9-
use nalgebra::{Matrix4, Point3, Vector3};
9+
use crate::math_ndsp::{Matrix4, Point3, Vector3};
1010
//use serde::{Deserialize, Serialize};
1111
use serde_wasm_bindgen::from_value; //, to_value};
1212
use wasm_bindgen::prelude::*;

0 commit comments

Comments
 (0)