Reference

std/geometry/plane

std/geometry/src/plane.trb

Plane, the flat surface in space, held as a normal and a distance: what a frustum, a ground and a clipping surface all are.

type Plane

type Plane<Scalar: Real = Float>

A flat surface, as the direction that points away from it and how far along that direction it lies.

A point is on the plane where normal.dot(point) == distance. The front is the side the normal points into, so Plane.signedDistanceTo is positive in front and negative behind - and which of the two a program calls "outside" is the program's own business.

Examples

const ground = Plane Vector3(0.0, 1.0, 0.0), 0.0
print "{ground.signedDistanceTo(Vector3(0.0, 2.0, 0.0))} {ground.closestPoint(to: Vector3(3.0, 2.0, 0.0))}"

Pitfalls

  • The normal is expected to have length one. Every constructor here answers one that has, and a plane built by writing the fields out is the caller's to normalize: with a longer normal the distances come out scaled.

Related

  • Ray3.hitsPlane - where a ray crosses one.
  • Triangle3.plane - the plane a triangle lies in.

field normal

normal: Vector3<Scalar>

The direction that points away from the front of the plane, with length one.

field distance

distance: Scalar

How far along the normal the plane lies, from the origin.

fn through

static fn through(point: Vector3<Scalar>, normal: Vector3<Scalar>): Plane<Scalar>

The plane through that point with that normal. The normal is normalized.

fn ofPoints

static fn ofPoints(first: Vector3<Scalar>, second: Vector3<Scalar>, third: Vector3<Scalar>): Plane<Scalar>

The plane through those three points, with the normal in the right-handed sense of their order.

fn signedDistanceTo

fn signedDistanceTo(point: Vector3<Scalar>): Scalar

How far the point is in front of the plane: negative behind it, zero exactly on it.

fn distanceTo

fn distanceTo(point: Vector3<Scalar>): Scalar

How far the point is from the plane, without a side.

fn isInFront

fn isInFront(point: Vector3<Scalar>): Bool

Whether the point is in front of the plane. A point exactly on it is not in front of it.

fn closestPoint

fn closestPoint(to: Vector3<Scalar>): Vector3<Scalar>

The point of the plane that is nearest to the one given.

fn mirrored

fn mirrored(point: Vector3<Scalar>): Vector3<Scalar>

The point mirrored in the plane.

fn flipped

fn flipped(): Plane<Scalar>

The same plane with the front on the other side.