Method GetClosestPointOnBoundary
- Namespace
- GeometryHelper.Core
- Assembly
- GeometryHelper.dll
GetClosestPointOnBoundary(GeoEllipse2, GeoPoint2)
Gets the point of the rim of an ellipse nearest a point, including for points inside it.
public static GeoPoint2 GetClosestPointOnBoundary(GeoEllipse2 ellipse, GeoPoint2 point)
Parameters
ellipseGeoEllipse2The ellipse.
pointGeoPoint2The point.
Returns
- GeoPoint2
The nearest point of the rim.
Remarks
Worked out by Eberly's robust method: the point is reflected into the first quadrant of the ellipse's own frame, the one root of the equation of the nearest point found there by halving a bracket, and the answer reflected back. It is right at the centre, on both axes, inside and outside, and for an ellipse a thousand times longer than it is wide.
Where two points of the rim are equally near, one is picked. The centre of an ellipse 300 by 100 is 100 from the two ends of the minor axis, and the one at t = 90° is given. A point on the major axis inside, nearer the centre than the centre of curvature of the end of the axis, is nearest two points mirrored across the axis, and the one on the positive side of the minor axis is given. The centre of a circle is as near every point of the rim, and the end of the minor axis at t = 90° is given there too, so that the answer does not jump between radii equal and radii a hair apart; GetClosestPointOnBoundary(GeoPoint2) gives the point at angle nought instead.