Skip to content

Plane

Represents a plane in 3D space.

Plane is stored in the implicit form , where normal is the plane normal and distance is the signed distance from the origin along that normal. It is commonly used for half-space tests, frustum planes, and simple clipping or culling operations.

Construction

Constructors


Plane() constexpr

Constructs a plane from a normal and distance.

cpp
Plane::Plane(const Vector3& normal, float distance);
ParameterDescription
normalPlane normal.
distanceSigned distance from the origin along the normal.

Properties

distance float

Signed distance from the origin to the plane along the normal.

cpp
float distance {0.0f};

normal Vector3

Plane normal vector.

cpp
Vector3 normal {Vector3::Up()};

Functions

DistanceToPoint() float

Computes the signed distance from the plane to a point.

Positive values are on the side pointed to by the normal, negative values are behind the plane, and zero lies on the plane.

cpp
float Plane::DistanceToPoint(const Vector3& point) const;
ParameterDescription
pointPoint to test.

DistanceToSphere() float

Computes the signed distance from the plane to a sphere surface.

The value is the distance from the plane to the closest point on the sphere. A negative value means the sphere penetrates the plane.

cpp
float Plane::DistanceToSphere(const Sphere& sphere) const;
ParameterDescription
sphereSphere to test.

Normalize() void

Normalizes the plane.

Scales normal to unit length and adjusts distance to preserve the plane equation.

cpp
void Plane::Normalize();

Released under the MIT License.