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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//! Point-projection result types.
//!
//! [`CurveProjection`], [`CurveProjection2D`] and [`SurfaceProjection`] are
//! returned by the `project_point` / `project_points` methods on curves and
//! surfaces: the closest parameter(s), the closest point itself (the curve or
//! surface evaluated there) and the distance from the query point.
//! Distances at or below the query tolerance are snapped to exactly `0.0`,
//! so `contains(point, tol)` agrees with
//! `project_point(point, tol).distance == 0.0`.
use crate::;
/// Closest point of a query point on a curve: the parameter, the point and
/// the distance.
///
/// # Examples
///
/// ```
/// use geomcore::{Line, Point, Tolerance, Vector};
///
/// let line = Line::new(Point::ORIGIN, Vector::X).unwrap();
/// let projection = line.project_point(Point::new(2.0, 1.0, 0.0), Tolerance::DEFAULT);
/// assert_eq!(projection.point, Point::new(2.0, 0.0, 0.0));
/// assert_eq!(projection.distance, 1.0);
/// ```
/// Closest point of a query point on a 2D curve: the parameter, the point and
/// the distance. The planar counterpart of [`CurveProjection`].
///
/// # Examples
///
/// ```
/// use geomcore::{Line2D, Point2D, Tolerance, Vector2D};
///
/// let line = Line2D::new(Point2D::ORIGIN, Vector2D::X).unwrap();
/// let projection = line.project_point(Point2D::new(2.0, 1.0), Tolerance::DEFAULT);
/// assert_eq!(projection.point, Point2D::new(2.0, 0.0));
/// assert_eq!(projection.distance, 1.0);
/// ```
/// Closest point of a query point on a surface: the parameters, the point and
/// the distance.
///
/// # Examples
///
/// ```
/// use geomcore::{Plane, Point, Tolerance, Vector};
///
/// let plane = Plane::new(Point::ORIGIN, Vector::Z).unwrap();
/// let projection = plane.project_point(Point::new(1.0, 2.0, 3.0), Tolerance::DEFAULT);
/// assert_eq!(projection.point, Point::new(1.0, 2.0, 0.0));
/// assert_eq!(projection.distance, 3.0);
/// ```
/// Snap a projection distance to `0.0` when it is within `confusion`.
///
/// This keeps projection coherent with [`crate::Tolerance`]-based
/// containment: a contained point projects to distance exactly zero.
pub