SaturnRingLibrary 0.9.1
SGL wrapper
 
Loading...
Searching...
No Matches
SRL::Math::Types::Plane Class Reference

Detailed Description

Infinite plane in 3D space defined by normal and distance for efficient geometric calculations.

The Plane class represents an infinite mathematical plane in 3D space using the standard form of the plane equation: normalĀ·X + d = 0, where:

  • normal: Unit vector perpendicular to the plane (defines orientation)
  • d: Signed distance from origin to plane along normal direction
  • X: Any point on the plane

Key features:

  • Memory-efficient representation (normal vector + distance scalar)
  • Constant-time distance calculations to points
  • Efficient intersection tests with rays, lines, and other geometric primitives
  • Multiple construction methods (3 points, normal+point, normal+distance)
  • Fixed-point arithmetic for consistent behavior across platforms

Mathematical properties:

  • Distance to point P is calculated as: normalĀ·P + d
    • Positive: Point is on same side as normal (in front of plane)
    • Zero: Point is exactly on the plane
    • Negative: Point is on opposite side from normal (behind plane)
  • The normal vector should always be normalized (unit length) for correct distance calculations
  • Planes can be used to define half-spaces for constructive solid geometry

Common applications:

  • Collision detection and response
  • View frustum culling (camera planes)
  • Constructive solid geometry (CSG)
  • Reflections and shadow calculations
  • Clipping algorithms
Note
For optimal performance, ensure the normal vector is normalized. Non-normalized normals will result in incorrect distance calculations.
See also
Frustum For usage of planes in camera view frustums
AABB For intersection tests between planes and bounding boxes

#include <plane.hpp>

Public Member Functions

constexpr Plane ()
 Default constructor. Creates XY plane at origin.
 
template<Precision P = Precision::Default>
 Plane (const Vector3D &a, const Vector3D &b, const Vector3D &c)
 Creates plane from three non-collinear points.
 
constexpr Plane (const Vector3D &normal, const Vector3D &point)
 Creates plane from normal and point.
 
constexpr Plane (const Vector3D &normal, Fxp d)
 Creates plane from normal and distance.
 
constexpr Fxp Distance (const Vector3D &point) const
 Calculates signed distance from point to plane.
 
template<Precision P = Precision::Default>
constexpr PlaneNormalize ()
 Normalizes the plane equation.
 
constexpr Vector3D Project (const Vector3D &point) const
 Projects point onto plane.
 

Public Attributes

Fxp d
 
Vector3D normal