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
use fj_math::{Line, Point, Vector};
use crate::objects::{Curve, CurveKind, GlobalCurve, Surface};
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 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(
CurveKind::Line(local),
GlobalCurve::from_kind(CurveKind::Line(global)),
)
}
}
pub struct GlobalCurveBuilder;
impl GlobalCurveBuilder {
pub fn x_axis(&self) -> GlobalCurve {
GlobalCurve::from_kind(CurveKind::x_axis())
}
pub fn y_axis(&self) -> GlobalCurve {
GlobalCurve::from_kind(CurveKind::y_axis())
}
pub fn z_axis(&self) -> GlobalCurve {
GlobalCurve::from_kind(CurveKind::z_axis())
}
pub fn line_from_points(
&self,
points: [impl Into<Point<3>>; 2],
) -> GlobalCurve {
let line = Line::from_points(points);
GlobalCurve::from_kind(CurveKind::Line(line))
}
}