Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::Plane< T > Class Template Reference

Math class that represents a plane in 3D. More...

Public Member Functions

 Plane (T normalX, T normalY, T normalZ, T Distance)
 Constructs a Plane object from its components. More...
 
 Plane (const T plane[4])
 Constructs a Plane object from an array of four elements. More...
 
 Plane (const Vector3< T > &Normal, T Distance)
 Constructs a Plane object from a normal and a distance. More...
 
 Plane (const Vector3< T > &Normal, const Vector3< T > &point)
 Constructs a Plane object from a normal and a point. More...
 
 Plane (const Vector3< T > &point1, const Vector3< T > &point2, const Vector3< T > &point3)
 Constructs a Plane object from three points. More...
 
template<typename U >
 Plane (const Plane< U > &plane)
 Constructs a Plane object from another type of Plane. More...
 
 Plane (const Plane &plane)=default
 
Distance (T x, T y, T z) const
 Returns the distance from the plane to the point. More...
 
Distance (const Vector3< T > &point) const
 Returns the distance from the plane to the point. More...
 
PlaneMakeXY ()
 Makes the plane (0, 0, 1, 0) More...
 
PlaneMakeXZ ()
 Makes the plane (0, 1, 0, 0) More...
 
PlaneMakeYZ ()
 Makes the plane (1, 0, 0, 0) More...
 
PlaneSet (T normalX, T normalY, T normalZ, T Distance)
 Sets the components of the plane. More...
 
PlaneSet (const T plane[4])
 Sets the components of the plane from an array of four elements. More...
 
PlaneSet (const Plane &plane)
 Sets the components of the plane from another plane. More...
 
PlaneSet (const Vector3< T > &Normal, T Distance)
 Sets the components of the plane from a normal and a distance. More...
 
PlaneSet (const Vector3< T > &Normal, const Vector3< T > &point)
 Sets the components of the plane from a normal and a point. More...
 
PlaneSet (const Vector3< T > &point1, const Vector3< T > &point2, const Vector3< T > &point3)
 Sets the components of the plane from three points. More...
 
template<typename U >
PlaneSet (const Plane< U > &plane)
 
String ToString () const
 Gives a string representation. More...
 
Planeoperator= (const Plane &other)=default
 
bool operator== (const Plane &plane) const
 Compares the plane to other one. More...
 
bool operator!= (const Plane &plane) const
 Compares the plane to other one. More...
 
template<typename U >
Plane< T > & Set (const Plane< U > &plane)
 Sets the components of the plane from another type of Plane. More...
 

Static Public Member Functions

static Plane Lerp (const Plane &from, const Plane &to, T interpolation)
 Interpolates the plane to other one with a factor of interpolation. More...
 
static Plane XY ()
 Shorthand for the plane (0, 0, 1, 0) More...
 
static Plane XZ ()
 Shorthand for the plane (0, 1, 0, 0) More...
 
static Plane YZ ()
 Shorthand for the plane (1, 0, 0, 0) More...
 

Public Attributes

Vector3< T > normal
 
distance
 

Detailed Description

template<typename T>
class Nz::Plane< T >

Math class that represents a plane in 3D.

Remarks
The convention used in this class is: If you ask for plane with normal (0, 1, 0) and distance 1, you will get 0 * X + 1 * Y + 0 * Z - 1 = 0 or Y = 1. Notice the sign minus before the distance on the left side of the equation

Constructor & Destructor Documentation

◆ Plane() [1/6]

template<typename T >
Nz::Plane< T >::Plane ( normalX,
normalY,
normalZ,
D 
)

Constructs a Plane object from its components.

Parameters
normalXX component of the normal
normalYY component of the normal
normalZZ component of the normal
DDistance to origin

◆ Plane() [2/6]

template<typename T >
Nz::Plane< T >::Plane ( const T  plane[4])

Constructs a Plane object from an array of four elements.

Parameters
plane[4]plane[0] is X component, plane[1] is Y component, plane[2] is Z component and plane[3] is D

◆ Plane() [3/6]

template<typename T >
Nz::Plane< T >::Plane ( const Vector3< T > &  Normal,
D 
)

Constructs a Plane object from a normal and a distance.

Parameters
Normalnormal of the vector
DDistance to origin

◆ Plane() [4/6]

template<typename T >
Nz::Plane< T >::Plane ( const Vector3< T > &  Normal,
const Vector3< T > &  point 
)

Constructs a Plane object from a normal and a point.

Parameters
NormalNormal of the plane
pointPoint which verifies the equation of the plane

◆ Plane() [5/6]

template<typename T >
Nz::Plane< T >::Plane ( const Vector3< T > &  point1,
const Vector3< T > &  point2,
const Vector3< T > &  point3 
)

Constructs a Plane object from three points.

Parameters
point1First point
point2Second point
point3Third point
Remarks
They are expected not to be colinear

◆ Plane() [6/6]

template<typename T >
template<typename U >
Nz::Plane< T >::Plane ( const Plane< U > &  plane)
explicit

Constructs a Plane object from another type of Plane.

Parameters
planePlane of type U to convert to type T

Member Function Documentation

◆ Distance() [1/2]

template<typename T >
T Nz::Plane< T >::Distance ( x,
y,
z 
) const

Returns the distance from the plane to the point.

Returns
Distance to the point
Parameters
XX position of the point
YY position of the point
ZZ position of the point
Remarks
If T is negative, it means that the point is in the opposite direction of the normal
See also
Distance

◆ Distance() [2/2]

template<typename T >
T Nz::Plane< T >::Distance ( const Vector3< T > &  point) const

Returns the distance from the plane to the point.

Returns
Distance to the point
Parameters
pointPosition of the point
Remarks
If T is negative, it means that the point is in the opposite direction of the normal
See also
Distance

◆ Lerp()

template<typename T >
Plane< T > Nz::Plane< T >::Lerp ( const Plane< T > &  from,
const Plane< T > &  to,
interpolation 
)
static

Interpolates the plane to other one with a factor of interpolation.

Returns
A new plane which is the interpolation of two planes
Parameters
fromInitial plane
toTarget plane
interpolationFactor of interpolation
Remarks
interpolation is meant to be between 0 and 1, other values are potentially undefined behavior
With NAZARA_DEBUG, a NazaraError is thrown and Plane() is returned
See also
Lerp

◆ MakeXY()

template<typename T >
Plane< T > & Nz::Plane< T >::MakeXY ( )

Makes the plane (0, 0, 1, 0)

Returns
A reference to this plane with components (0, 0, 1, 0)
See also
XY

◆ MakeXZ()

template<typename T >
Plane< T > & Nz::Plane< T >::MakeXZ ( )

Makes the plane (0, 1, 0, 0)

Returns
A reference to this plane with components (0, 1, 0, 0)
See also
XZ

◆ MakeYZ()

template<typename T >
Plane< T > & Nz::Plane< T >::MakeYZ ( )

Makes the plane (1, 0, 0, 0)

Returns
A reference to this plane with components (1, 0, 0, 0)
See also
YZ

◆ operator!=()

template<typename T >
bool Nz::Plane< T >::operator!= ( const Plane< T > &  plane) const

Compares the plane to other one.

Returns
false if the planes are the same
Parameters
planeOther plane to compare with
Remarks
Plane with normal N and distance D is the same than with normal -N et distance -D

◆ operator==()

template<typename T >
bool Nz::Plane< T >::operator== ( const Plane< T > &  plane) const

Compares the plane to other one.

Returns
true if the planes are the same
Parameters
vecOther vector to compare with
Remarks
Plane with normal N and distance D is the same than with normal -N et distance -D

◆ Set() [1/7]

template<typename T >
Plane< T > & Nz::Plane< T >::Set ( normalX,
normalY,
normalZ,
D 
)

Sets the components of the plane.

Returns
A reference to this plane
Parameters
normalXX component of the normal
normalYY component of the normal
normalZZ component of the normal
DDistance to origin

◆ Set() [2/7]

template<typename T >
Plane< T > & Nz::Plane< T >::Set ( const T  plane[4])

Sets the components of the plane from an array of four elements.

Returns
A reference to this plane
Parameters
plane[4]plane[0] is X component, plane[1] is Y component, plane[2] is Z component and plane[3] is D

◆ Set() [3/7]

template<typename T >
Plane< T > & Nz::Plane< T >::Set ( const Plane< T > &  plane)

Sets the components of the plane from another plane.

Returns
A reference to this plane
Parameters
planeThe other plane

◆ Set() [4/7]

template<typename T >
Plane< T > & Nz::Plane< T >::Set ( const Vector3< T > &  Normal,
D 
)

Sets the components of the plane from a normal and a distance.

Returns
A reference to this plane
Parameters
NormalNormal of the vector
DDistance to origin

◆ Set() [5/7]

template<typename T >
Plane< T > & Nz::Plane< T >::Set ( const Vector3< T > &  Normal,
const Vector3< T > &  point 
)

Sets the components of the plane from a normal and a point.

Returns
A reference to this plane
Parameters
NormalNormal of the plane
pointPoint which verifies the equation of the plane

◆ Set() [6/7]

template<typename T >
Plane< T > & Nz::Plane< T >::Set ( const Vector3< T > &  point1,
const Vector3< T > &  point2,
const Vector3< T > &  point3 
)

Sets the components of the plane from three points.

Returns
A reference to this plane
Parameters
point1First point
point2Second point
point3Third point
Remarks
They are expected not to be colinear

◆ Set() [7/7]

template<typename T>
template<typename U >
Plane<T>& Nz::Plane< T >::Set ( const Plane< U > &  plane)

Sets the components of the plane from another type of Plane.

Returns
A reference to this plane
Parameters
planePlane of type U to convert its components

◆ ToString()

template<typename T >
String Nz::Plane< T >::ToString ( ) const

Gives a string representation.

Returns
A string representation of the object: "Plane(Normal: Vector3(x, y, z); Distance: w)"

◆ XY()

template<typename T >
Plane< T > Nz::Plane< T >::XY ( )
static

Shorthand for the plane (0, 0, 1, 0)

Returns
A plane with components (0, 0, 1, 0)
See also
MakeXY

◆ XZ()

template<typename T >
Plane< T > Nz::Plane< T >::XZ ( )
static

Shorthand for the plane (0, 1, 0, 0)

Returns
A plane with components (0, 1, 0, 0)
See also
MakeXZ

◆ YZ()

template<typename T >
Plane< T > Nz::Plane< T >::YZ ( )
static

Shorthand for the plane (1, 0, 0, 0)

Returns
A plane with components (1, 0, 0, 0)
See also
MakeYZ

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