#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) |
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.
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. |
|
inline |
The default constructor. Does not initialize anything. So this does not result in a usable/valid plane.
|
inline |
Constructor when you know the normal of the plane and a point on the plane.
norm | The normal of the plane. |
pnt | A point on the plane. |
|
inline |
Constructor when you know the normal and the value of d out of the plane equation (Ax + By + Cz + d = 0)
norm | The normal of the plane |
d | The value of 'd' out of the plane equation. |
|
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().
v1 | The first point on the plane. |
v2 | The second point on the plane. |
v3 | The third point on the plane. |
|
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.
v | The vector representing the 3D point to use for the calculation. |
|
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.
|
inline |
Construct the plane when the normal of the plane and a point on the plane are known.
normal | The normal of the plane. |
pointOnPlane | A point on the plane. |
|
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)
normal | The normal of the plane. |
d | The value of 'd' in the above mentioned plane equation. |
|
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()
v1 | The first point on the plane. |
v2 | The second point on the plane. |
v3 | The third point on the plane. |
|
inline |
Get the 'd' out of the plane equation (Ax + By + Cz + d = 0).
|
inline |
Get the normal of the plane.
|
inline |
Project a vector onto the plane.
vectorToProject | The vector you wish to project onto the plane. |