1
+ /// Definitions used in documentation for this module;
2
+ ///
3
+ /// - **line**:
4
+ /// - The straight path on a plane that
5
+ /// - extends infinitely in both directions.
6
+ /// - defined by two distinct points `a` and `b` and
7
+ /// - has the direction of the vector from `a` to `b`
8
+ ///
9
+ /// - **segment**:
10
+ /// - A finite portion of a `line` which
11
+ /// - lies between the points `a` and `b`
12
+ /// - has the direction of the vector from `a` to `b`
13
+ ///
14
+ /// - **ray**:
15
+ /// - A segment which extends infinitely in the forward direction
16
+ ///
17
+ /// - `Line`: the type [crate::Line] which is actually a **segment**.
18
+
1
19
use super :: vector_extensions:: VectorExtensions ;
2
20
use crate :: {
3
21
Coord ,
@@ -8,39 +26,42 @@ use crate::{
8
26
// Orientation
9
27
} ;
10
28
11
- // No nested enums :( Goes into the enum below
29
+ /// Used to encode the relationship between a **segment** and an intersection
30
+ /// point. See documentation for [LineIntersectionResultWithRelationships]
31
+ #[ derive( PartialEq , Eq , Debug , Clone , Copy ) ]
32
+ pub ( super ) enum LineSegmentIntersectionType {
33
+ /// The intersection point lies between the start and end of the **segment**
34
+ ///
35
+ /// Abbreviated to `TIP` in original paper
36
+ TrueIntersectionPoint ,
37
+ /// The intersection point is 'false' or 'virtual': it lies on the same
38
+ /// **line** as the **segment**, but not between the start and end points of
39
+ /// the **segment**.
40
+ ///
41
+ /// Abbreviated to `FIP` in original paper
42
+
43
+ // Note: Rust does not permit nested enum declaration, so
44
+ // FalseIntersectionPointType has to be declared below.
45
+ FalseIntersectionPoint ( FalseIntersectionPointType ) ,
46
+ }
47
+
48
+ /// These are the variants of [LineSegmentIntersectionType::FalseIntersectionPoint]
12
49
#[ derive( PartialEq , Eq , Debug , Clone , Copy ) ]
13
50
pub ( super ) enum FalseIntersectionPointType {
14
- /// The intersection point is 'false' or 'virtual': it lies on the infinite
15
- /// ray defined by the line segment, but before the start of the line segment.
51
+ /// The intersection point is 'false' or 'virtual': it lies on the same
52
+ /// **line** as the ** segment**, and before the start of the ** segment** .
16
53
///
17
54
/// Abbreviated to `NFIP` in original paper (Negative)
18
55
/// (also referred to as `FFIP` in Figure 6, but i think this is an
19
56
/// error?)
20
57
BeforeStart ,
21
- /// The intersection point is 'false' or 'virtual': it lies on the infinite
22
- /// ray defined by the line segment, but after the end of the line segment.
58
+ /// The intersection point is 'false' or 'virtual': it lies on the same
59
+ /// **line** as the ** segment**, and after the end of the ** segment** .
23
60
///
24
61
/// Abbreviated to `PFIP` in original paper (Positive)
25
62
AfterEnd ,
26
63
}
27
64
28
- /// Used to encode the relationship between a segment (e.g. between [Coord] `a` and `b`)
29
- /// and an intersection point ([Coord] `p`)
30
- #[ derive( PartialEq , Eq , Debug , Clone , Copy ) ]
31
- pub ( super ) enum LineSegmentIntersectionType {
32
- /// The intersection point lies between the start and end of the line segment.
33
- ///
34
- /// Abbreviated to `TIP` in original paper
35
- TrueIntersectionPoint ,
36
- /// The intersection point is 'false' or 'virtual': it lies on the infinite
37
- /// ray defined by the line segment, but not between the start and end points
38
- ///
39
- /// Abbreviated to `FIP` in original paper
40
- FalseIntersectionPoint ( FalseIntersectionPointType ) ,
41
- }
42
-
43
-
44
65
45
66
/// Struct to contain the result for [line_segment_intersection_with_relationships]
46
67
#[ derive( Clone , Debug ) ]
@@ -169,7 +190,8 @@ where
169
190
}
170
191
171
192
// TODO:
172
- // The above could be replaced with the following.
193
+ // The above could be replaced with the following, but at the cost of
194
+ // repeating some computation.
173
195
174
196
// match RobustKernel::orient2d(*a, *b, *d) {
175
197
// Orientation::Collinear => None,
0 commit comments