Ocean
Ocean::PlaneT3< T > Class Template Reference

This class implements a plane in 3D space. More...

Inheritance diagram for Ocean::PlaneT3< T >:

Public Types

typedef T Type
 Definition of the used data type. More...
 

Public Member Functions

 PlaneT3 ()=default
 Creates an invalid plane. More...
 
 PlaneT3 (const VectorT3< T > &point, const VectorT3< T > &normal)
 Creates a plane by an intersection point and a normal. More...
 
 PlaneT3 (const VectorT3< T > &point0, const VectorT3< T > &point1, const VectorT3< T > &point2)
 Creates a plane by three points lying in the plane. More...
 
 PlaneT3 (const VectorT3< T > &normal, const T distance)
 Creates a plane by the plane's normal and the distance between origin and plane. More...
 
 PlaneT3 (const T yaw, const T pitch, const T distance)
 Creates a plane by the plane's normal and the distance between origin and plane. More...
 
 PlaneT3 (const HomogenousMatrixT4< T > &transformation)
 Creates a plane by a transformation where the z-axis defined the plane's normal and the origin or the transformation defines a point on the plane. More...
 
bool isInPlane (const VectorT3< T > &point, const T epsilon=NumericT< T >::eps()) const
 Returns whether a point is in the plane. More...
 
signedDistance (const VectorT3< T > &point) const
 Returns the distance between a given point and this plane. More...
 
VectorT3< T > projectOnPlane (const VectorT3< T > &point) const
 Projects a given point onto the plane. More...
 
VectorT3< T > reflect (const VectorT3< T > &direction)
 Reflects a given vector in the plane. More...
 
const VectorT3< T > & normal () const
 Returns the normal of the plane. More...
 
const T & distance () const
 Returns the distance between plane and origin. More...
 
void decomposeNormal (T &yaw, T &pitch) const
 Calculates the yaw and pitch angle of the plane's normal. More...
 
PlaneT3< T > transform (const HomogenousMatrixT4< T > &iTransformation) const
 Transforms this plane so that it corresponds to a new coordinate system. More...
 
bool transformation (const VectorT3< T > &pointOnPlane, const VectorT3< T > &upVector, HomogenousMatrixT4< T > &matrix) const
 Determines a transformation having the origin in a given point on the plane, with z-axis corresponding to the normal of the plane and with y-axis corresponding to a given (projected) up-vector. More...
 
void setNormal (const VectorT3< T > &normal)
 Sets the normal of this plane. More...
 
void setDistance (const T distance)
 Sets the distance between plane and origin. More...
 
VectorT3< T > pointOnPlane () const
 Returns a point on the plane. More...
 
bool intersection (const LineT3< T > &ray, VectorT3< T > &point) const
 Calculates the intersection between this plane and a given ray. More...
 
bool intersection (const PlaneT3< T > &plane, LineT3< T > &line) const
 Calculates the intersection between this plane and a second plane. More...
 
bool isValid () const
 Returns whether this plane is valid. More...
 
bool isEqual (const PlaneT3< T > &plane, const T eps=NumericT< T >::eps()) const
 Returns whether two plane objects represent the same plane up to a specified epsilon. More...
 
 operator bool () const
 Returns whether the plane has a normal with non-zero length. More...
 
PlaneT3< T > operator- () const
 Returns an inverted plane of this plane having an inverted normal direction (and adjusted distance). More...
 
bool operator== (const PlaneT3< T > &right) const
 Returns whether two plane objects represent the same plane. More...
 
bool operator!= (const PlaneT3< T > &right) const
 Returns whether two plane objects do not represent the same plane. More...
 

Protected Attributes

VectorT3< T > normal_ = VectorT3<T>(0, 0, 0)
 Normal of the plane. More...
 
distance_ = T(0)
 Distance of the plane. More...
 

Detailed Description

template<typename T>
class Ocean::PlaneT3< T >

This class implements a plane in 3D space.

The plane is defined by:
(x - p)n = 0, xn - pn = 0, xn - d = 0,
with Intersection point p, normal n and distance d.

Template Parameters
TData type used to represent the plane
See also
Plane3, PlaneF3, PlaneD3.

Member Typedef Documentation

◆ Type

template<typename T >
typedef T Ocean::PlaneT3< T >::Type

Definition of the used data type.

Constructor & Destructor Documentation

◆ PlaneT3() [1/6]

template<typename T >
Ocean::PlaneT3< T >::PlaneT3 ( )
default

Creates an invalid plane.

◆ PlaneT3() [2/6]

template<typename T >
Ocean::PlaneT3< T >::PlaneT3 ( const VectorT3< T > &  point,
const VectorT3< T > &  normal 
)

Creates a plane by an intersection point and a normal.

Parameters
pointIntersection point of the plane
normalUnit vector perpendicular to the plane

◆ PlaneT3() [3/6]

template<typename T >
Ocean::PlaneT3< T >::PlaneT3 ( const VectorT3< T > &  point0,
const VectorT3< T > &  point1,
const VectorT3< T > &  point2 
)

Creates a plane by three points lying in the plane.

To create a valid plane three individual non-collinear points must be provided.
However, due to performance reasons this constructor accepts any kind of 3D object points but may create an invalid plane.
Thus, check whether the plane is valid after creation.

Parameters
point0First intersection point
point1Second intersection point
point2Third intersection point
See also
isValid().

◆ PlaneT3() [4/6]

template<typename T >
Ocean::PlaneT3< T >::PlaneT3 ( const VectorT3< T > &  normal,
const T  distance 
)

Creates a plane by the plane's normal and the distance between origin and plane.

Parameters
normalPlane normal, must have length 1
distanceThe signed distance between origin and plane, with range (-infinity, infinity)

◆ PlaneT3() [5/6]

template<typename T >
Ocean::PlaneT3< T >::PlaneT3 ( const T  yaw,
const T  pitch,
const T  distance 
)

Creates a plane by the plane's normal and the distance between origin and plane.

The plane's normal is provided in yaw and pitch angles from an Euler rotation.
The default normal (with yaw and pitch zero) looks along the negative z-axis.

Parameters
yawThe yaw angle of the plane's normal, in radian
pitchThe pitch angle of the plane's normal, in radian
distanceThe distance between origin and plane

◆ PlaneT3() [6/6]

template<typename T >
Ocean::PlaneT3< T >::PlaneT3 ( const HomogenousMatrixT4< T > &  transformation)
explicit

Creates a plane by a transformation where the z-axis defined the plane's normal and the origin or the transformation defines a point on the plane.

The z-axis will be normalized before it is assigned as normal of the plane.

Parameters
transformationThe transformation from which a plane will be defined

Member Function Documentation

◆ decomposeNormal()

template<typename T >
void Ocean::PlaneT3< T >::decomposeNormal ( T &  yaw,
T &  pitch 
) const
inline

Calculates the yaw and pitch angle of the plane's normal.

The angles are related to an Euler rotation while the default normal (with angles zero) looks along the negative z-axis.

Parameters
yawResulting yaw angle, in radian
pitchResulting pitch angle, in radian

◆ distance()

template<typename T >
const T & Ocean::PlaneT3< T >::distance
inline

Returns the distance between plane and origin.

Returns
Plane distance

◆ intersection() [1/2]

template<typename T >
bool Ocean::PlaneT3< T >::intersection ( const LineT3< T > &  ray,
VectorT3< T > &  point 
) const

Calculates the intersection between this plane and a given ray.

Parameters
rayThe ray for which the intersection will be calculated, must be valid
pointResulting intersection point
Returns
True, if the ray has an intersection with this plane

intersection point: ray.point() + t * ray.direction() t = (plane.distance() - plane.normal() * ray.point()) / (plane.normal() * ray.direction())

◆ intersection() [2/2]

template<typename T >
bool Ocean::PlaneT3< T >::intersection ( const PlaneT3< T > &  plane,
LineT3< T > &  line 
) const

Calculates the intersection between this plane and a second plane.

Parameters
planeThe second plane for which the intersection will be calculated, must be valid
lineResulting intersection line
Returns
True, if the second plane has an intersection with this plane (if both planes are not parallel)

◆ isEqual()

template<typename T >
bool Ocean::PlaneT3< T >::isEqual ( const PlaneT3< T > &  plane,
const T  eps = NumericT<T>::eps() 
) const
inline

Returns whether two plane objects represent the same plane up to a specified epsilon.

Two planes are identical if their normal vector and distance value is identical or inverted.

Parameters
planeThe second plane to compare
epsThe epsilon value to be used, with range [0, infinity)
Returns
True, if so

◆ isInPlane()

template<typename T >
bool Ocean::PlaneT3< T >::isInPlane ( const VectorT3< T > &  point,
const T  epsilon = NumericT<T>::eps() 
) const

Returns whether a point is in the plane.

Parameters
pointThe point to check
epsilonThe epsilon value defining the accuracy threshold, with range [0, infinity)
Returns
True, if so

◆ isValid()

template<typename T >
bool Ocean::PlaneT3< T >::isValid

Returns whether this plane is valid.

A valid plane has a normal with length 1.

Returns
True, if so

◆ normal()

template<typename T >
const VectorT3< T > & Ocean::PlaneT3< T >::normal
inline

Returns the normal of the plane.

Returns
Plane normal

◆ operator bool()

template<typename T >
Ocean::PlaneT3< T >::operator bool
inlineexplicit

Returns whether the plane has a normal with non-zero length.

Beware: A plane with non-zero length normal may be invalid, however.

Returns
True, if so

◆ operator!=()

template<typename T >
bool Ocean::PlaneT3< T >::operator!= ( const PlaneT3< T > &  right) const
inline

Returns whether two plane objects do not represent the same plane.

Parameters
rightSecond plane to compare
Returns
True, if so

◆ operator-()

template<typename T >
PlaneT3< T > Ocean::PlaneT3< T >::operator-
inline

Returns an inverted plane of this plane having an inverted normal direction (and adjusted distance).

Returns
The inverted plane

◆ operator==()

template<typename T >
bool Ocean::PlaneT3< T >::operator== ( const PlaneT3< T > &  right) const
inline

Returns whether two plane objects represent the same plane.

Two planes are identical if their normal vector and distance value is identical or inverted.

Parameters
rightSecond plane to compare
Returns
True, if so

◆ pointOnPlane()

template<typename T >
VectorT3< T > Ocean::PlaneT3< T >::pointOnPlane
inline

Returns a point on the plane.

Returns
Point on plane

◆ projectOnPlane()

template<typename T >
VectorT3< T > Ocean::PlaneT3< T >::projectOnPlane ( const VectorT3< T > &  point) const

Projects a given point onto the plane.

Parameters
pointThe point that will be projected
Returns
The projected point

◆ reflect()

template<typename T >
VectorT3< T > Ocean::PlaneT3< T >::reflect ( const VectorT3< T > &  direction)

Reflects a given vector in the plane.

The given vector should point towards the plane.

Parameters
directionThe direction vector being reflected
Returns
The reflected vector

◆ setDistance()

template<typename T >
void Ocean::PlaneT3< T >::setDistance ( const T  distance)
inline

Sets the distance between plane and origin.

Parameters
distancePlane distance to be set

◆ setNormal()

template<typename T >
void Ocean::PlaneT3< T >::setNormal ( const VectorT3< T > &  normal)
inline

Sets the normal of this plane.

Parameters
normalThe normal to be set, must have length 1.

◆ signedDistance()

template<typename T >
T Ocean::PlaneT3< T >::signedDistance ( const VectorT3< T > &  point) const

Returns the distance between a given point and this plane.

The distance will be positive for points on the side of the plane that its normal pointing to and negative on the other.

Parameters
pointThe point for which the distance will be determined
Returns
Distance between plane and point, with range (-infinity, infinity)

◆ transform()

template<typename T >
PlaneT3< T > Ocean::PlaneT3< T >::transform ( const HomogenousMatrixT4< T > &  iTransformation) const

Transforms this plane so that it corresponds to a new coordinate system.

Parameters
iTransformationThe inverse of a new coordinate system (defining the transformation from points defined in the coordinate system of this current plane to points defined in the new coordinate system)
Returns
Resulting new plane for the given (inverted) coordinate system

◆ transformation()

template<typename T >
bool Ocean::PlaneT3< T >::transformation ( const VectorT3< T > &  pointOnPlane,
const VectorT3< T > &  upVector,
HomogenousMatrixT4< T > &  matrix 
) const

Determines a transformation having the origin in a given point on the plane, with z-axis corresponding to the normal of the plane and with y-axis corresponding to a given (projected) up-vector.

Parameters
pointOnPlaneA 3D point on this 3D plane at which the origin of the transformation will be located
upVectorAn up-vector starting at the given point on the 3D plane, the vector will be projected onto the plane and normalized to define the y-axis of the transformation, can be e.g., the viewing direction of the camera, must not be parallel to the plane's normal
matrixThe resulting matrix defining the transformation
Returns
True, if succeeded

Field Documentation

◆ distance_

template<typename T >
T Ocean::PlaneT3< T >::distance_ = T(0)
protected

Distance of the plane.

◆ normal_

template<typename T >
VectorT3<T> Ocean::PlaneT3< T >::normal_ = VectorT3<T>(0, 0, 0)
protected

Normal of the plane.


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