Skip to content

Commit d95420f

Browse files
improve docs for line_intersection enum
1 parent 63409d3 commit d95420f

File tree

1 file changed

+44
-22
lines changed

1 file changed

+44
-22
lines changed

geo/src/algorithm/offset_curve/line_intersection.rs

+44-22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
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+
119
use super::vector_extensions::VectorExtensions;
220
use crate::{
321
Coord,
@@ -8,39 +26,42 @@ use crate::{
826
// Orientation
927
};
1028

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]
1249
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
1350
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**.
1653
///
1754
/// Abbreviated to `NFIP` in original paper (Negative)
1855
/// (also referred to as `FFIP` in Figure 6, but i think this is an
1956
/// error?)
2057
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**.
2360
///
2461
/// Abbreviated to `PFIP` in original paper (Positive)
2562
AfterEnd,
2663
}
2764

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-
4465

4566
/// Struct to contain the result for [line_segment_intersection_with_relationships]
4667
#[derive(Clone, Debug)]
@@ -169,7 +190,8 @@ where
169190
}
170191

171192
// 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.
173195

174196
// match RobustKernel::orient2d(*a, *b, *d) {
175197
// Orientation::Collinear => None,

0 commit comments

Comments
 (0)