Table of Contents

Method ProjectToTriangle

Namespace
GeometryHelper.Core
Assembly
GeometryHelper.dll

ProjectToTriangle(GeoTriangle3, GeoPoint3)

Projects a point onto a triangle, clamped to its edges.

public static GeoPoint3 ProjectToTriangle(GeoTriangle3 triangle, GeoPoint3 point)

Parameters

triangle GeoTriangle3

The triangle to project onto.

point GeoPoint3

The point to project.

Returns

GeoPoint3

The point of the triangle closest to the supplied point.

Remarks

This is the Voronoi region method: the space around a triangle divides into seven regions — one per vertex, one per edge, and the interior — and each is recognised by the signs of a handful of dot products before any division happens. Solving the barycentric system directly instead would divide by a determinant that vanishes for a degenerate triangle, which is exactly the input the fallback at the end of this method handles.