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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
use fj_math::{Line, Point, Scalar, Vector};
use crate::{
objects::{Curve, GlobalCurve, Surface},
path::{GlobalPath, SurfacePath},
};
pub struct CurveBuilder {
surface: Surface,
}
impl CurveBuilder {
pub fn new(surface: Surface) -> Self {
Self { surface }
}
pub fn u_axis(&self) -> Curve {
let a = Point::origin();
let b = a + Vector::unit_u();
self.line_from_points([a, b])
}
pub fn v_axis(&self) -> Curve {
let a = Point::origin();
let b = a + Vector::unit_v();
self.line_from_points([a, b])
}
pub fn circle_from_radius(&self, radius: impl Into<Scalar>) -> Curve {
let radius = radius.into();
let path = SurfacePath::circle_from_radius(radius);
let global_form = GlobalCurveBuilder.circle_from_radius(radius);
Curve::new(self.surface, path, global_form)
}
pub fn line_from_points(&self, points: [impl Into<Point<2>>; 2]) -> Curve {
let points = points.map(Into::into);
let local = Line::from_points(points);
let global = Line::from_points(
points.map(|point| self.surface.point_from_surface_coords(point)),
);
Curve::new(
self.surface,
SurfacePath::Line(local),
GlobalCurve::from_path(GlobalPath::Line(global)),
)
}
}
pub struct GlobalCurveBuilder;
impl GlobalCurveBuilder {
pub fn x_axis(&self) -> GlobalCurve {
GlobalCurve::from_path(GlobalPath::x_axis())
}
pub fn y_axis(&self) -> GlobalCurve {
GlobalCurve::from_path(GlobalPath::y_axis())
}
pub fn z_axis(&self) -> GlobalCurve {
GlobalCurve::from_path(GlobalPath::z_axis())
}
pub fn circle_from_radius(&self, radius: impl Into<Scalar>) -> GlobalCurve {
let path = GlobalPath::circle_from_radius(radius);
GlobalCurve::from_path(path)
}
pub fn line_from_points(
&self,
points: [impl Into<Point<3>>; 2],
) -> GlobalCurve {
let line = Line::from_points(points);
GlobalCurve::from_path(GlobalPath::Line(line))
}
}