Open 3D Engine EMotionFX Gem API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
MCore::PlaneEq Class Reference

#include <PlaneEq.h>

Public Types

enum  EPlane { PLANE_XY = 0 , PLANE_XZ = 1 , PLANE_YZ = 2 }
 

Public Member Functions

MCORE_INLINE PlaneEq ()
 
MCORE_INLINE PlaneEq (const AZ::Vector3 &norm, const AZ::Vector3 &pnt)
 
MCORE_INLINE PlaneEq (const AZ::Vector3 &norm, float d)
 
MCORE_INLINE PlaneEq (const AZ::Vector3 &v1, const AZ::Vector3 &v2, const AZ::Vector3 &v3)
 
MCORE_INLINE EPlane CalcDominantPlane () const
 
MCORE_INLINE float CalcDistanceTo (const AZ::Vector3 &v) const
 
MCORE_INLINE void Construct (const AZ::Vector3 &normal, const AZ::Vector3 &pointOnPlane)
 
MCORE_INLINE void Construct (const AZ::Vector3 &normal, float d)
 
MCORE_INLINE void Construct (const AZ::Vector3 &v1, const AZ::Vector3 &v2, const AZ::Vector3 &v3)
 
MCORE_INLINE const AZ::Vector3 & GetNormal () const
 
MCORE_INLINE float GetDist () const
 
MCORE_INLINE AZ::Vector3 Project (const AZ::Vector3 &vectorToProject)
 

Detailed Description

The Plane Equation template. This represents an infinite plane, which is mathematically represented by the following equation: Ax + By + Cz + d = 0. Where ABC is the XYZ of the planes normal and where xyz is a point on the plane. The value d is a constant value, which is precalculated. Now if we put a random point inside this equation, when we already know the normal and the value for d, we can see if the result of Ax + By + Cz + d is 0 or not. If it is 0, this means the point is on the plane. We can also use this to calculate on what side of the plane a point is. This is for example used for constructing BSP trees. So, from this we can conclude that the result of (normal.Dot(point) + d) is the distance from point to the plane, along the planes normal.

Member Enumeration Documentation

◆ EPlane

Axis aligned planes. Used to determine the most dominant axis, which can be used for planar mapping. This is for example used to generate the texture coordinates for lightmaps.

Enumerator
PLANE_XY 

The XY plane, so where Z is constant.

PLANE_XZ 

The XZ plane, so where Y is constant.

PLANE_YZ 

The YZ plane, so where X is constant.

Constructor & Destructor Documentation

◆ PlaneEq() [1/4]

MCORE_INLINE MCore::PlaneEq::PlaneEq ( )
inline

The default constructor. Does not initialize anything. So this does not result in a usable/valid plane.

◆ PlaneEq() [2/4]

MCORE_INLINE MCore::PlaneEq::PlaneEq ( const AZ::Vector3 &  norm,
const AZ::Vector3 &  pnt 
)
inline

Constructor when you know the normal of the plane and a point on the plane.

Parameters
normThe normal of the plane.
pntA point on the plane.

◆ PlaneEq() [3/4]

MCORE_INLINE MCore::PlaneEq::PlaneEq ( const AZ::Vector3 &  norm,
float  d 
)
inline

Constructor when you know the normal and the value of d out of the plane equation (Ax + By + Cz + d = 0)

Parameters
normThe normal of the plane
dThe value of 'd' out of the plane equation.

◆ PlaneEq() [4/4]

MCORE_INLINE MCore::PlaneEq::PlaneEq ( const AZ::Vector3 &  v1,
const AZ::Vector3 &  v2,
const AZ::Vector3 &  v3 
)
inline

Constructor when you know 3 points on the plane (the winding matters here (clockwise vs counter-clockwise) The normal will be calculated as ((v2-v1).Cross(v3-v1)).Normalize().

Parameters
v1The first point on the plane.
v2The second point on the plane.
v3The third point on the plane.

Member Function Documentation

◆ CalcDistanceTo()

MCORE_INLINE float MCore::PlaneEq::CalcDistanceTo ( const AZ::Vector3 &  v) const
inline

Calculates the distance of a given point to the plane, along the normal. A mathematical explanation of how this is done can be read in the description of this template/class.

Parameters
vThe vector representing the 3D point to use for the calculation.
Returns
The distance from 'v' to this plane, along the normal of this plane.

◆ CalcDominantPlane()

MCORE_INLINE EPlane MCore::PlaneEq::CalcDominantPlane ( ) const
inline

Calculates and returns the dominant plane. A dominant plane is an axis aligned plane, so it can be 3 types of planes, one for each axis. The way this is calculated is by looking at the normal of the plane, and looking which axis of the normal is the most dominant. Based on this, corresponding axis aligned plane, can be returned.

Returns
Returns the type of axis aligned plane. This can be aligned to the XY, XZ or YZ plane. See EPlane for the plane types.

◆ Construct() [1/3]

MCORE_INLINE void MCore::PlaneEq::Construct ( const AZ::Vector3 &  normal,
const AZ::Vector3 &  pointOnPlane 
)
inline

Construct the plane when the normal of the plane and a point on the plane are known.

Parameters
normalThe normal of the plane.
pointOnPlaneA point on the plane.

◆ Construct() [2/3]

MCORE_INLINE void MCore::PlaneEq::Construct ( const AZ::Vector3 &  normal,
float  d 
)
inline

Construct the plane when the normal of the plane is known, as well as the value of 'd' in the plane equation (Ax + By + Cz + d = 0)

Parameters
normalThe normal of the plane.
dThe value of 'd' in the above mentioned plane equation.

◆ Construct() [3/3]

MCORE_INLINE void MCore::PlaneEq::Construct ( const AZ::Vector3 &  v1,
const AZ::Vector3 &  v2,
const AZ::Vector3 &  v3 
)
inline

Construct the plane when you know three points on the plane. The winding of the vertices matters (clockwise vs counter-clockwise). The normal is calculated as ((v2-v1).Cross(v3-v1)).Normalize()

Parameters
v1The first point on the plane.
v2The second point on the plane.
v3The third point on the plane.

◆ GetDist()

MCORE_INLINE float MCore::PlaneEq::GetDist ( ) const
inline

Get the 'd' out of the plane equation (Ax + By + Cz + d = 0).

Returns
Returns the 'd' from the plane equation.

◆ GetNormal()

MCORE_INLINE const AZ::Vector3& MCore::PlaneEq::GetNormal ( ) const
inline

Get the normal of the plane.

Returns
Returns the normal of the plane.

◆ Project()

MCORE_INLINE AZ::Vector3 MCore::PlaneEq::Project ( const AZ::Vector3 &  vectorToProject)
inline

Project a vector onto the plane.

Parameters
vectorToProjectThe vector you wish to project onto the plane.
Returns
The projected vector.

The documentation for this class was generated from the following file: