Skip to content

Engine → Core → plane.h

plane

Syntax

struct plane

Variables

AccessNameTypeDefaultDescription
publicdistancef320.0f
publicnormalvec3vec3(0.0f, 1.0f, 0.0f)

Functions

Public

from_point_normal

[[nodiscard]] static plane from_point_normal(
    vec3 point,
    vec3 direction) noexcept;

The plane through point with the given normal, normalised. A zero normal yields the default (Y up) plane through the point.

from_points

[[nodiscard]] static plane from_points(
    vec3 a,
    vec3 b,
    vec3 c) noexcept;

The plane through three counter-clockwise points (normal = cross(b - a, c - a)), normalised. Collinear points yield the default (Y up) plane through a.

normalize

void normalize() noexcept;

Scales the equation so that the normal has unit length. A zero normal is left as is.

normalized

[[nodiscard]] plane normalized() const noexcept;

A copy with normalize() applied.

project

[[nodiscard]] vec3 project(
    vec3 point) const noexcept;

The orthogonal projection of a point onto the plane (requires a unit normal).

signed_distance

[[nodiscard]] f32 signed_distance(
    vec3 point) const noexcept;

dot(normal, point) + distance: positive in front of the plane, negative behind, zero on it. A metric distance only when the normal has unit length.

Operator Overloads

Public

operator==

[[nodiscard]] bool operator==(
    const plane &other) const = default;