Three noncollinear points define a plane. Their order sets the sign.
dotnet add package RecursiveAI.OneMathRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using RecursiveAI.OneMath.Predicates; var side = ExactPredicates.Orient3D( 0, 0, 0, 1, 0, 0, 0, 1, 0, // Plane 0, 0, 1); // Point Console.WriteLine(side);
Unzip the example, then dotnet run.
-1The vertices run counterclockwise when seen from above, so Orient3D returns -1 for a point above the plane and +1 for one below.
The full program
using RecursiveAI.OneMath; using RecursiveAI.OneMath.Predicates; Vector3D a = new(0, 0, 0), b = new(1, 0, 0), c = new(0, 1, 0); Vector3D above = new(0, 0, 1), below = new(0, 0, -1); Vector3D onPlane = new(2, 2, 0); Console.WriteLine($"Above: {Side(a, b, c, above)}"); Console.WriteLine($"Below: {Side(a, b, c, below)}"); Console.WriteLine($"On plane: {Side(a, b, c, onPlane)}"); Console.WriteLine($"Reversed: {Side(a, c, b, above)}"); static int Side(Vector3D a, Vector3D b, Vector3D c, Vector3D p) => ExactPredicates.Orient3D(a.X, a.Y, a.Z, b.X, b.Y, b.Z, c.X, c.Y, c.Z, p.X, p.Y, p.Z);
dotnet run prints:
Above: -1 Below: 1 On plane: 0 Reversed: 1
Collinear or repeated vertices don’t define a plane; use a nondegenerate triangle and finite coordinates in the documented range.
Variations
To test whether two points are strictly on opposite sides, compare their nonzero signs:
using RecursiveAI.OneMath.Predicates; // Same XY plane for both tests. Only the query point changes. int first = ExactPredicates.Orient3D( 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1); int second = ExactPredicates.Orient3D( 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, -1); Console.WriteLine(first != 0 && second == -first);
TrueRelated recipes
The short answer
Call ExactPredicates.Orient3D with the XYZ coordinates of three ordered, noncollinear vertices followed by the query point’s XYZ coordinates. A zero means the point is on their plane; -1 and +1 mean opposite sides. See the pinned predicate specification.
How do you determine which side of a plane a point is on?
Pick a consistent order for the three vertices that define your plane. The example uses the XY plane and takes the vertex at the origin first, the one on +X second, and the one on +Y third. This order runs counterclockwise viewed from +Z. Swapping the second and third vertices reverses the sign for a point off the plane without moving the plane. For a tilted plane, the sign still comes from the vertex order, not from whether a point has a larger Z coordinate than the vertices.
OneMath takes the sign of the determinant whose rows are the vertices relative to the query point. A swap exchanges two rows, reversing the determinant’s sign. That’s why the opposite-side variation has the same answer if you reverse the triangle for both calls. Orient3D returns a sign, not a signed distance; the magnitude 1 doesn’t mean the point is one unit away.
How do you know if a point is on a plane?
For a triangle that defines a plane, a return value of 0 means exact coplanarity of the supplied double values within the documented range. No epsilon is needed to interpret that result. The full program’s point (2, 2, 0) is outside the triangle but on the plane: coplanarity is not a point-in-triangle test.
The exactness guarantee applies when every coordinate is zero or has magnitude from 2⁻¹⁴⁰ through 2²⁰⁰, inclusive. Nonfinite coordinates throw ArgumentOutOfRangeException; finite coordinates outside the guaranteed range may also throw. The predicate operates on the values you give it, so if a measurement or a prior transform already rounded them, it classifies those rounded coordinates. A point that is close enough for a measurement tolerance is a different question from exact coplanarity.