Unravel Engine C++ Reference
Loading...
Searching...
No Matches
math::plane Struct Reference

Storage for infinite plane. More...

#include <plane.h>

Public Member Functions

 plane ()
 Default constructor.
 
 plane (const vec4 &p)
 Constructor from a vec4.
 
 plane (float _a, float _b, float _c, float _d)
 Constructor from individual float components.
 
auto operator* (float s) const -> plane
 Multiplies the plane by a scalar value.
 
auto operator/ (float s) const -> plane
 Divides the plane by a scalar value.
 
auto operator*= (float s) -> plane &
 Multiplies and assigns the plane by a scalar value.
 
auto operator/= (float s) -> plane &
 Divides and assigns the plane by a scalar value.
 
auto operator+ () const -> plane
 Unary plus operator.
 
auto operator- () const -> plane
 Unary minus operator.
 
auto operator== (const plane &p) const -> bool
 Equality operator.
 
auto operator!= (const plane &p) const -> bool
 Inequality operator.
 
auto operator= (const vec4 &rhs) -> plane &
 Assignment operator from vec4.
 

Static Public Member Functions

static auto dot (const plane &p, const vec4 &v) -> float
 Computes the dot product of the plane and a vec4.
 
static auto dot_coord (const plane &p, const vec3 &v) -> float
 Computes the dot product of the plane and a vec3 (considering the plane's distance).
 
static auto dot_normal (const plane &p, const vec3 &v) -> float
 Computes the dot product of the plane normal and a vec3.
 
static auto from_point_normal (const vec3 &point, const vec3 &normal) -> plane
 Creates a plane from a point and a normal.
 
static auto from_points (const vec3 &v1, const vec3 &v2, const vec3 &v3) -> plane
 Creates a plane from three points.
 
static auto mul (const plane &p, const mat4 &m) -> plane
 Transforms a plane by a 4x4 matrix.
 
static auto normalize (const plane &p) -> plane
 Normalizes the plane.
 
static auto scale (const plane &p, float s) -> plane
 Scales the plane by a scalar value.
 

Public Attributes

vec4 data = {0.0f, 0.0f, 0.0f, 0.0f}
 The components of the plane.
 

Friends

auto operator* (float s, const plane &p) -> plane
 Scalar multiplication for a plane.
 

Detailed Description

Storage for infinite plane.

Definition at line 20 of file plane.h.

Constructor & Destructor Documentation

◆ plane() [1/3]

math::plane::plane ( )
default

Default constructor.

Initializes the plane with all components set to zero.

◆ plane() [2/3]

math::plane::plane ( const vec4 & p)

Constructor from a vec4.

Initializes the plane with the given vec4 components.

Parameters
pA vec4 representing the plane components.

Definition at line 98 of file plane.cpp.

◆ plane() [3/3]

math::plane::plane ( float _a,
float _b,
float _c,
float _d )

Constructor from individual float components.

Initializes the plane with the given components.

Parameters
_aThe x component of the plane normal.
_bThe y component of the plane normal.
_cThe z component of the plane normal.
_dThe distance component of the plane.

Definition at line 102 of file plane.cpp.

Member Function Documentation

◆ dot()

auto math::plane::dot ( const plane & p,
const vec4 & v ) -> float
static

Computes the dot product of the plane and a vec4.

Parameters
pThe plane.
vThe vec4.
Returns
The dot product as a float.

Definition at line 5 of file plane.cpp.

◆ dot_coord()

auto math::plane::dot_coord ( const plane & p,
const vec3 & v ) -> float
static

Computes the dot product of the plane and a vec3 (considering the plane's distance).

Parameters
pThe plane.
vThe vec3.
Returns
The dot product as a float.

Definition at line 10 of file plane.cpp.

◆ dot_normal()

auto math::plane::dot_normal ( const plane & p,
const vec3 & v ) -> float
static

Computes the dot product of the plane normal and a vec3.

Parameters
pThe plane.
vThe vec3.
Returns
The dot product as a float.

Definition at line 15 of file plane.cpp.

◆ from_point_normal()

auto math::plane::from_point_normal ( const vec3 & point,
const vec3 & normal ) -> plane
static

Creates a plane from a point and a normal.

Parameters
pointA point on the plane.
normalThe normal vector of the plane.
Returns
A new plane defined by the point and normal.

Definition at line 20 of file plane.cpp.

◆ from_points()

auto math::plane::from_points ( const vec3 & v1,
const vec3 & v2,
const vec3 & v3 ) -> plane
static

Creates a plane from three points.

Parameters
v1The first point.
v2The second point.
v3The third point.
Returns
A new plane defined by the three points.

Definition at line 26 of file plane.cpp.

◆ mul()

auto math::plane::mul ( const plane & p,
const mat4 & m ) -> plane
static

Transforms a plane by a 4x4 matrix.

Parameters
pThe plane to be transformed.
mThe transformation matrix.
Returns
A new transformed plane.

Definition at line 32 of file plane.cpp.

◆ normalize()

auto math::plane::normalize ( const plane & p) -> plane
static

Normalizes the plane.

Normalizes the plane's normal vector and adjusts the distance component.

Parameters
pThe plane to be normalized.
Returns
A new normalized plane.

Definition at line 37 of file plane.cpp.

◆ operator!=()

auto math::plane::operator!= ( const plane & p) const -> bool

Inequality operator.

Checks if two planes are not equal.

Parameters
pThe plane to compare with.
Returns
True if the planes are not equal, false otherwise.

Definition at line 85 of file plane.cpp.

◆ operator*()

auto math::plane::operator* ( float s) const -> plane

Multiplies the plane by a scalar value.

Parameters
sThe scalar value to multiply by.
Returns
A new plane with each component multiplied by the scalar value.

Definition at line 48 of file plane.cpp.

◆ operator*=()

auto math::plane::operator*= ( float s) -> plane&

Multiplies and assigns the plane by a scalar value.

Parameters
sThe scalar value to multiply by.
Returns
A reference to the plane after multiplication.

Definition at line 58 of file plane.cpp.

◆ operator+()

auto math::plane::operator+ ( ) const -> plane

Unary plus operator.

Returns
A copy of the plane.

Definition at line 70 of file plane.cpp.

◆ operator-()

auto math::plane::operator- ( ) const -> plane

Unary minus operator.

Negates all components of the plane.

Returns
A new plane with all components negated.

Definition at line 75 of file plane.cpp.

◆ operator/()

auto math::plane::operator/ ( float s) const -> plane

Divides the plane by a scalar value.

Parameters
sThe scalar value to divide by.
Returns
A new plane with each component divided by the scalar value.

Definition at line 53 of file plane.cpp.

◆ operator/=()

auto math::plane::operator/= ( float s) -> plane&

Divides and assigns the plane by a scalar value.

Parameters
sThe scalar value to divide by.
Returns
A reference to the plane after division.

Definition at line 64 of file plane.cpp.

◆ operator=()

auto math::plane::operator= ( const vec4 & rhs) -> plane&

Assignment operator from vec4.

Assigns the components of the plane from a vec4.

Parameters
rhsThe vec4 to assign from.
Returns
A reference to the plane after assignment.

Definition at line 90 of file plane.cpp.

◆ operator==()

auto math::plane::operator== ( const plane & p) const -> bool

Equality operator.

Checks if two planes are equal.

Parameters
pThe plane to compare with.
Returns
True if the planes are equal, false otherwise.

Definition at line 80 of file plane.cpp.

◆ scale()

auto math::plane::scale ( const plane & p,
float s ) -> plane
static

Scales the plane by a scalar value.

Multiplies each component of the plane by the given scalar value.

Parameters
pThe plane to be scaled.
sThe scalar value to multiply by.
Returns
A new scaled plane.

Definition at line 43 of file plane.cpp.

Friends And Related Symbol Documentation

◆ operator*

auto operator* ( float s,
const plane & p ) -> plane
friend

Scalar multiplication for a plane.

Multiplies each component of the plane by a scalar value.

Parameters
sScalar value to multiply by.
pThe plane to be multiplied.
Returns
A new plane with each component multiplied by the scalar value.

Definition at line 255 of file plane.h.

Member Data Documentation

◆ data

vec4 math::plane::data = {0.0f, 0.0f, 0.0f, 0.0f}

The components of the plane.

The first three components represent the normal vector of the plane, and the fourth component represents the distance from the origin.

Definition at line 240 of file plane.h.


The documentation for this struct was generated from the following files: