Kanzi  3.9.9
Kanzi Engine C++ API
kanzi::Plane Class Reference

The equation of a plane in 3D space is defined with a normal vector (perpendicular to that plane) and a known point on the plane. More...

#include <kanzi/core/math/plane.hpp>

Public Member Functions

float getA () const
 Gets the a coefficient of a plane. More...
 
float getB () const
 Get the b coefficient of a plane. More...
 
float getC () const
 Get the c coefficient of a plane. More...
 
float getD () const
 Get the d coefficient of a plane. More...
 
float getDistance () const
 Gets the distance between a plane and an origin. More...
 
float getDistanceToPoint (const Vector3 point) const
 Gets the distance from a given point to a plane. More...
 
Vector3 getNormal () const
 Gets the normal component of a plane. More...
 
 Plane ()
 Default constructor. More...
 
 Plane (const Vector3 normal, const float distance)
 Constructor. More...
 
 Plane (const float x, const float y, const float z, const float distance)
 Constructor. More...
 
Vector3 projectDirection (const Vector3 direction) const
 Project a direction vector onto a plane. More...
 
Vector3 projectPosition (const Vector3 position) const
 Project a position vector onto a plane. More...
 

Static Public Member Functions

static Plane createFromPointAndNormal (const Vector3 point, const Vector3 normal)
 Creates a plane from a point and a normal. More...
 

Detailed Description

The equation of a plane in 3D space is defined with a normal vector (perpendicular to that plane) and a known point on the plane.

If the normal vector is normalized (unit length), then the constant term of the plane equation becomes the distance from the origin. For a normal vector (a, b, c), the point P1 on the plane becomes (d*a, d*b, d*c), where d is the distance from the origin. The equation of the plane can be written with the unit vector and the point on the plane in order to show the distance d is the constant term of the equation. Mathematically, a plane is defined as: a*x + b*y + c*z + d = 0, where d is the distance from origin.

Constructor & Destructor Documentation

kanzi::Plane::Plane ( )
inlineexplicit

Default constructor.

Initializes the plane components to identity: a=0, b=0, c=0, d=0.

kanzi::Plane::Plane ( const Vector3  normal,
const float  distance 
)
inlineexplicit

Constructor.

Constructs a plane from a normal vector and a distance from an origin.

Parameters
normalThe normal component of a plane.
distanceThe distance from the origin to a plane.
kanzi::Plane::Plane ( const float  x,
const float  y,
const float  z,
const float  distance 
)
inlineexplicit

Constructor.

Constructs a plane from a normal (x,y,z) and a distance from an origin.

Parameters
xThe x coefficient of a normal of a plane.
yThe y coefficient of a normal of a plane.
zThe z coefficient of a normal of a plane.
distanceThe distance from the origin to the plane.

Member Function Documentation

static Plane kanzi::Plane::createFromPointAndNormal ( const Vector3  point,
const Vector3  normal 
)
static

Creates a plane from a point and a normal.

The normal must be of unit length.

Parameters
pointA point on the plane that you want to create.
normalA normal vector to the plane that you want to create.
Returns
The plane created from the given point and normal.
Vector3 kanzi::Plane::getNormal ( ) const
inline

Gets the normal component of a plane.

Returns
The normal component of a plane.
float kanzi::Plane::getDistance ( ) const
inline

Gets the distance between a plane and an origin.

Returns
The distance from a plane to an origin.
float kanzi::Plane::getA ( ) const
inline

Gets the a coefficient of a plane.

Returns
The a coefficient of the plane equation.
float kanzi::Plane::getB ( ) const
inline

Get the b coefficient of a plane.

Returns
The b coefficient of the plane equation.
float kanzi::Plane::getC ( ) const
inline

Get the c coefficient of a plane.

Returns
The c coefficient of the plane equation.
float kanzi::Plane::getD ( ) const
inline

Get the d coefficient of a plane.

Returns
The d coefficient of the plane equation.
float kanzi::Plane::getDistanceToPoint ( const Vector3  point) const

Gets the distance from a given point to a plane.

Parameters
pointThe point vector from which to calculate the distance to a plane.
Returns
The distance from the given point to the plane.
Vector3 kanzi::Plane::projectDirection ( const Vector3  direction) const

Project a direction vector onto a plane.

Parameters
directionThe direction vector that you want to project.
Returns
The projected direction on the plane.
Vector3 kanzi::Plane::projectPosition ( const Vector3  position) const

Project a position vector onto a plane.

Parameters
positionThe position vector that you want to project.
Returns
The projected point on the plane.

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