Math::PlaneEquation struct

Public types

enum class Intersection { None, Point, InPlane }
The type of intersection between the plane and a line.

Constructors, destructors, conversion operators

PlaneEquation()
PlaneEquation(const PlaneEquation& other)
PlaneEquation(float a, float b, float c, float d)
PlaneEquation(const Vector3& normal, const Vector3& point)
PlaneEquation(const Vector3& u, const Vector3& v, const Vector3& point)

Public functions

auto GetNormal() const -> Vector3
Returns the normal vector of the plane; this vector is perpendicular to the plane.
auto GetPointOnPlane() const -> Vector3
Returns an arbitrary point that is contained on the plane, might not be the same as the one used in the constructor.
auto IsOnPlane(const Vector3& point, float epsilon = 1e-7f) const -> bool
Returns whether a given point is inside the plane.
auto IntersectRay(const Vector3& point, const Vector3& direction, Vector3& dst) const -> Intersection
Calculates the intesection between a ray (semi-infinite line) and the plane.
auto ProjectPoint(const Vector3& point) const -> Vector3
Returns the projection of the point onto the plane: that is the point inside the plane that is closest to the given point.
auto ProjectVector(const Vector3& v) const -> Vector3
Returns the projection of the vector onto the plane.

Public variables

float a
float b
float c
float d

Enum documentation

enum class Math::PlaneEquation::Intersection

The type of intersection between the plane and a line.

Enumerators
None

Point

InPlane

Infinite intersection points, the line is contained inside the plane.

Function documentation

Vector3 Math::PlaneEquation::GetNormal() const

Returns the normal vector of the plane; this vector is perpendicular to the plane.

Returns The normal vector of the plane.

Vector3 Math::PlaneEquation::GetPointOnPlane() const

Returns an arbitrary point that is contained on the plane, might not be the same as the one used in the constructor.

Returns A point in the plane

bool Math::PlaneEquation::IsOnPlane(const Vector3& point, float epsilon = 1e-7f) const

Returns whether a given point is inside the plane.

Parameters
point The point to be evaluated
epsilon Tolerancy
Returns True if the point is in the plane, false otherwise.

A certain tolerancy can be specified.

Intersection Math::PlaneEquation::IntersectRay(const Vector3& point, const Vector3& direction, Vector3& dst) const

Calculates the intesection between a ray (semi-infinite line) and the plane.

Parameters
point Start point of the ray
direction Direction of the ray
dst out Where the intersection point will be written. Only valid if returns Intersection::Point
Returns The type of intersection

The ray is defined by the start point and a direction; only positive multiples of the direction will be considered.

A ray can intersect with a plane in 3 different ways:

  • Intersection::None, line is parallel to plane
  • Intersection::Point, line intersects with the plane in only one point
  • Intersection::InPlane, line is parallel to plane and contained within it, so all points of the ray are inside the plane Only in the one point case this method gives a valid result.

Vector3 Math::PlaneEquation::ProjectPoint(const Vector3& point) const

Returns the projection of the point onto the plane: that is the point inside the plane that is closest to the given point.

Parameters
point The point to project
Returns The projected point, which is contained in the plane

Vector3 Math::PlaneEquation::ProjectVector(const Vector3& v) const

Returns the projection of the vector onto the plane.

Parameters
v The vector to project
Returns The projected vector.

This only considers the plane normal and not its position, since its irrelevant for a vector.