@@ -6,12 +6,23 @@ use super::GlobalPath;
6
6
7
7
/// The geometry that defines a surface
8
8
#[ derive( Clone , Copy , Debug , Eq , PartialEq , Hash , Ord , PartialOrd ) ]
9
- pub struct SurfaceGeom {
10
- /// The u-axis of the surface
11
- pub u : GlobalPath ,
12
-
13
- /// The v-axis of the surface
14
- pub v : Vector < 3 > ,
9
+ pub enum SurfaceGeom {
10
+ /// # Basic definition of surface geometry
11
+ ///
12
+ /// ## Implementation Note
13
+ ///
14
+ /// At the time of writing, this is the sole variant of `SurfaceGeom`.
15
+ /// `SurfaceGeom` simply used to be a struct, identical to this variant.
16
+ ///
17
+ /// This was changed as part of a transition to a new, less basic and more
18
+ /// flexible, representation of surface geometry.
19
+ Basic {
20
+ /// The u-axis of the surface
21
+ u : GlobalPath ,
22
+
23
+ /// The v-axis of the surface
24
+ v : Vector < 3 > ,
25
+ } ,
15
26
}
16
27
17
28
impl SurfaceGeom {
@@ -21,7 +32,7 @@ impl SurfaceGeom {
21
32
point : impl Into < Point < 2 > > ,
22
33
) -> Point < 3 > {
23
34
let point = point. into ( ) ;
24
- let Self { u, .. } = self ;
35
+ let Self :: Basic { u, .. } = self ;
25
36
u. point_from_path_coords ( [ point. u ] )
26
37
+ self . path_to_line ( ) . vector_from_line_coords ( [ point. v ] )
27
38
}
@@ -32,19 +43,19 @@ impl SurfaceGeom {
32
43
vector : impl Into < Vector < 2 > > ,
33
44
) -> Vector < 3 > {
34
45
let vector = vector. into ( ) ;
35
- let Self { u, .. } = self ;
46
+ let Self :: Basic { u, .. } = self ;
36
47
u. vector_from_path_coords ( [ vector. u ] )
37
48
+ self . path_to_line ( ) . vector_from_line_coords ( [ vector. v ] )
38
49
}
39
50
40
51
fn path_to_line ( & self ) -> Line < 3 > {
41
- let Self { u, v } = self ;
52
+ let Self :: Basic { u, v } = self ;
42
53
Line :: from_origin_and_direction ( u. origin ( ) , * v)
43
54
}
44
55
45
56
/// Project the global point into the surface
46
57
pub fn project_global_point ( & self , point : impl Into < Point < 3 > > ) -> Point < 2 > {
47
- let Self { u, v } = self ;
58
+ let Self :: Basic { u, v } = self ;
48
59
49
60
let GlobalPath :: Line ( line) = u else {
50
61
todo ! ( "Projecting point into non-plane surface is not supported" )
@@ -57,11 +68,11 @@ impl SurfaceGeom {
57
68
/// Transform the surface geometry
58
69
#[ must_use]
59
70
pub fn transform ( self , transform : & Transform ) -> Self {
60
- let Self { u, v } = self ;
71
+ let Self :: Basic { u, v } = self ;
61
72
62
73
let u = u. transform ( transform) ;
63
74
let v = transform. transform_vector ( & v) ;
64
- Self { u, v }
75
+ Self :: Basic { u, v }
65
76
}
66
77
}
67
78
@@ -74,7 +85,7 @@ mod tests {
74
85
75
86
#[ test]
76
87
fn point_from_surface_coords ( ) {
77
- let surface = SurfaceGeom {
88
+ let surface = SurfaceGeom :: Basic {
78
89
u : GlobalPath :: Line ( Line :: from_origin_and_direction (
79
90
Point :: from ( [ 1. , 1. , 1. ] ) ,
80
91
Vector :: from ( [ 0. , 2. , 0. ] ) ,
@@ -90,7 +101,7 @@ mod tests {
90
101
91
102
#[ test]
92
103
fn vector_from_surface_coords ( ) {
93
- let surface = SurfaceGeom {
104
+ let surface = SurfaceGeom :: Basic {
94
105
u : GlobalPath :: Line ( Line :: from_origin_and_direction (
95
106
Point :: from ( [ 1. , 0. , 0. ] ) ,
96
107
Vector :: from ( [ 0. , 2. , 0. ] ) ,
0 commit comments