mirror of
https://github.com/hannobraun/Fornjot
synced 2025-10-24 16:58:20 +00:00
Add Increment::snap_to_multiple
This commit is contained in:
parent
3ef7ce6214
commit
93f1f173a7
@ -83,9 +83,8 @@ impl CurveGeometry for Circle {
|
||||
|
||||
let mut curvature = Vec::new();
|
||||
|
||||
let mut t =
|
||||
snap_to_increment(min.t, increment.inner.t) + increment.inner.t;
|
||||
while t <= snap_to_increment(max.t, increment.inner.t) {
|
||||
let mut t = increment.snap_to_multiple(min.t) + increment.inner.t;
|
||||
while t <= increment.snap_to_multiple(max.t) {
|
||||
curvature.push(Point::from([t]));
|
||||
t += increment.inner.t;
|
||||
}
|
||||
@ -112,10 +111,6 @@ impl CurveGeometry for Circle {
|
||||
}
|
||||
}
|
||||
|
||||
fn snap_to_increment(t: Scalar, increment: Scalar) -> Scalar {
|
||||
(t / increment).floor() * increment
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::f64::consts::{FRAC_PI_2, FRAC_PI_4, PI};
|
||||
|
||||
@ -157,6 +157,12 @@ pub struct Increment {
|
||||
pub inner: Vector<1>,
|
||||
}
|
||||
|
||||
impl Increment {
|
||||
pub fn snap_to_multiple(&self, t: Scalar) -> Scalar {
|
||||
(t / self.inner.t).floor() * self.inner.t
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use fj_math::{Point, Vector};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user