-
-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathmod.rs
49 lines (40 loc) · 1.06 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Sweeping objects along a path to create new objects
mod edge;
mod face;
mod sketch;
use fj_interop::mesh::Color;
use fj_math::{Scalar, Vector};
use super::Tolerance;
/// Sweep an object along a path to create another object
pub trait Sweep {
/// The object that is created by sweeping the implementing object
type Swept;
/// Sweep the object along the given path
fn sweep(
self,
path: impl Into<Path>,
tolerance: Tolerance,
color: Color,
) -> Self::Swept;
}
/// A path to be used with [`Sweep`]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct Path(Vector<3>);
impl Path {
/// Return the vector that defines this path
pub fn inner(&self) -> Vector<3> {
self.0
}
/// Indicate whether the path is in the negative direction
pub fn is_negative_direction(&self) -> bool {
self.0.dot(&Vector::from([0., 0., 1.])) < Scalar::ZERO
}
}
impl<T> From<T> for Path
where
T: Into<Vector<3>>,
{
fn from(value: T) -> Self {
Self(value.into())
}
}