---
title: "Find which side of a plane a point is on in C#"
url: https://recursiveai.org/onemath/cookbook/classify-point-side-of-plane/
description: "Classify a point against a plane defined by three ordered points in C#. OneMath’s Orient3D reports the side or exact coplanarity in its supported range."
version: "1.0.0"
---

# Find which side of a plane a point is on in C#

**OneMath** is a free, open-source deterministic math library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneMath) · [GitHub](https://github.com/recursive-ai-oss/onemath-csharp) · [Docs](https://recursiveai.org/onemath/docs/) · [Download example (.zip)](https://recursiveai.org/onemath/cookbook/classify-point-side-of-plane/classify-point-side-of-plane.zip)

Three noncollinear points define a plane. Their order sets the sign.

```shell
dotnet add package RecursiveAI.OneMath
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
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](https://recursiveai.org/onemath/cookbook/classify-point-side-of-plane/classify-point-side-of-plane.zip), then `dotnet run`.

```text
-1
```

The 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

```csharp
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:

```text
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](https://recursiveai.org/onemath/docs/predicates/#input-requirements-and-range).

## Variations

To test whether two points are strictly on opposite sides, compare their nonzero signs:

```csharp
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);
```

```text
True
```

## Related recipes

- [Exact geometric predicates](https://recursiveai.org/onemath/cookbook/exact-predicates/)
- [Test if a point is inside a tetrahedron](https://recursiveai.org/onemath/cookbook/test-point-inside-tetrahedron/)

## 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](https://github.com/recursive-ai-oss/onemath-csharp/blob/1986f32ecb9f5f3001c0121484f104c489720334/docs/predicates.md#L13-L27).

## 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.
