Ocean
|
This class implements a plane in 3D space. More...
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... | |
T | 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... | |
T | distance_ = T(0) |
Distance of the plane. More... | |
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.
T | Data type used to represent the plane |
typedef T Ocean::PlaneT3< T >::Type |
Definition of the used data type.
|
default |
Creates an invalid plane.
Ocean::PlaneT3< T >::PlaneT3 | ( | const VectorT3< T > & | point, |
const VectorT3< T > & | normal | ||
) |
Creates a plane by an intersection point and a normal.
point | Intersection point of the plane |
normal | Unit vector perpendicular to the plane |
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.
point0 | First intersection point |
point1 | Second intersection point |
point2 | Third intersection point |
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.
normal | Plane normal, must have length 1 |
distance | The signed distance between origin and plane, with range (-infinity, infinity) |
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.
yaw | The yaw angle of the plane's normal, in radian |
pitch | The pitch angle of the plane's normal, in radian |
distance | The distance between origin and plane |
|
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.
transformation | The transformation from which a plane will be defined |
|
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.
yaw | Resulting yaw angle, in radian |
pitch | Resulting pitch angle, in radian |
|
inline |
Returns the distance between plane and origin.
bool Ocean::PlaneT3< T >::intersection | ( | const LineT3< T > & | ray, |
VectorT3< T > & | point | ||
) | const |
Calculates the intersection between this plane and a given ray.
ray | The ray for which the intersection will be calculated, must be valid |
point | Resulting intersection point |
intersection point: ray.point() + t * ray.direction() t = (plane.distance() - plane.normal() * ray.point()) / (plane.normal() * ray.direction())
bool Ocean::PlaneT3< T >::intersection | ( | const PlaneT3< T > & | plane, |
LineT3< T > & | line | ||
) | const |
Calculates the intersection between this plane and a second plane.
plane | The second plane for which the intersection will be calculated, must be valid |
line | Resulting intersection line |
|
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.
plane | The second plane to compare |
eps | The epsilon value to be used, with range [0, infinity) |
bool Ocean::PlaneT3< T >::isInPlane | ( | const VectorT3< T > & | point, |
const T | epsilon = NumericT<T>::eps() |
||
) | const |
Returns whether a point is in the plane.
point | The point to check |
epsilon | The epsilon value defining the accuracy threshold, with range [0, infinity) |
bool Ocean::PlaneT3< T >::isValid |
Returns whether this plane is valid.
A valid plane has a normal with length 1.
|
inline |
Returns the normal of the plane.
|
inlineexplicit |
Returns whether the plane has a normal with non-zero length.
Beware: A plane with non-zero length normal may be invalid, however.
|
inline |
Returns whether two plane objects do not represent the same plane.
right | Second plane to compare |
|
inline |
Returns an inverted plane of this plane having an inverted normal direction (and adjusted distance).
|
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.
right | Second plane to compare |
|
inline |
Returns a point on the plane.
VectorT3< T > Ocean::PlaneT3< T >::projectOnPlane | ( | const VectorT3< T > & | point | ) | const |
Projects a given point onto the plane.
point | The point that will be projected |
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.
direction | The direction vector being reflected |
|
inline |
Sets the distance between plane and origin.
distance | Plane distance to be set |
|
inline |
Sets the normal of this plane.
normal | The normal to be set, must have length 1. |
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.
point | The point for which the distance will be determined |
PlaneT3< T > Ocean::PlaneT3< T >::transform | ( | const HomogenousMatrixT4< T > & | iTransformation | ) | const |
Transforms this plane so that it corresponds to a new coordinate system.
iTransformation | The 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) |
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.
pointOnPlane | A 3D point on this 3D plane at which the origin of the transformation will be located |
upVector | An 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 |
matrix | The resulting matrix defining the transformation |
|
protected |
Distance of the plane.
|
protected |
Normal of the plane.