A plane and related functions. More...
#include <gz/math/Plane.hh>
Public Types | |
enum | PlaneSide { NEGATIVE_SIDE = 0 , POSITIVE_SIDE = 1 , NO_SIDE = 2 , BOTH_SIDE = 3 } |
Enum used to indicate a side of the plane, no side, or both sides for entities on the plane. More... | |
Public Member Functions | |
Plane () | |
Constructor. More... | |
Plane (const Plane &_plane)=default | |
Copy constructor. More... | |
Plane (const Vector3< T > &_normal, const Vector2< T > &_size, T _offset) | |
Constructor. More... | |
Plane (const Vector3< T > &_normal, T _offset=0.0) | |
Constructor from a normal and a distance. More... | |
~Plane ()=default | |
Destructor. More... | |
T | Distance (const Vector3< T > &_origin, const Vector3< T > &_dir) const |
Get distance to the plane give an origin and direction. More... | |
T | Distance (const Vector3< T > &_point) const |
The distance to the plane from the given point. The distance can be negative, which indicates the point is on the negative side of the plane. More... | |
std::optional< Vector3< T > > | Intersection (const Vector3< T > &_point, const Vector3< T > &_gradient, const double &_tolerance=1e-6) const |
Get the intersection of an infinite line with the plane, given the line's gradient and a point in parametrized space. More... | |
Vector3< T > & | Normal () |
Get the plane normal. More... | |
const Vector3< T > & | Normal () const |
Get the plane normal. More... | |
T | Offset () const |
Get the plane offset. More... | |
Plane< T > & | operator= (const Plane< T > &_p)=default |
Equal operator. More... | |
void | Set (const Vector3< T > &_normal, const Vector2< T > &_size, T _offset) |
Set the plane. More... | |
void | Set (const Vector3< T > &_normal, T _offset) |
Set the plane. More... | |
PlaneSide | Side (const math::AxisAlignedBox &_box) const |
The side of the plane a box is on. More... | |
PlaneSide | Side (const Vector3< T > &_point) const |
The side of the plane a point is on. More... | |
Vector2< T > & | Size () |
Get the plane size. More... | |
const Vector2< T > & | Size () const |
Get the plane size. More... | |
Detailed Description
template<typename T>
class gz::math::Plane< T >
A plane and related functions.
Member Enumeration Documentation
◆ PlaneSide
enum PlaneSide |
Enum used to indicate a side of the plane, no side, or both sides for entities on the plane.
- See also
- Side
Constructor & Destructor Documentation
◆ Plane() [1/4]
|
inline |
Constructor.
◆ Plane() [2/4]
Constructor from a normal and a distance.
- Parameters
-
[in] _normal The plane normal [in] _offset Offset along the normal
◆ Plane() [3/4]
Constructor.
- Parameters
-
[in] _normal The plane normal [in] _size Size of the plane [in] _offset Offset along the normal
References Plane< T >::Set().
◆ Plane() [4/4]
◆ ~Plane()
|
default |
Destructor.
Member Function Documentation
◆ Distance() [1/2]
Get distance to the plane give an origin and direction.
- Parameters
-
[in] _origin the origin [in] _dir a direction
- Returns
- the shortest distance
References Vector3< T >::Dot().
◆ Distance() [2/2]
|
inline |
The distance to the plane from the given point. The distance can be negative, which indicates the point is on the negative side of the plane.
- Parameters
-
[in] _point 3D point to calculate distance from.
- Returns
- Distance from the point to the plane.
- See also
- Side
Referenced by Plane< T >::Side().
◆ Intersection()
|
inline |
Get the intersection of an infinite line with the plane, given the line's gradient and a point in parametrized space.
- Parameters
-
[in] _point A point that lies on the line. [in] _gradient The gradient of the line. [in] _tolerance The tolerance for determining a line is parallel to the plane. Optional, default=10^-16
- Returns
- The point of intersection. std::nullopt if the line is parallel to the plane (including lines on the plane).
References Vector3< T >::Cross(), Vector3< T >::Dot(), Plane< T >::Normal(), Plane< T >::Offset(), and Plane< T >::Size().
◆ Normal() [1/2]
|
inline |
Get the plane normal.
◆ Normal() [2/2]
|
inline |
Get the plane normal.
Referenced by Plane< T >::Intersection().
◆ Offset()
|
inline |
Get the plane offset.
Referenced by Plane< T >::Intersection().
◆ operator=()
Equal operator.
- Parameters
-
_p another plane
- Returns
- itself
◆ Set() [1/2]
Set the plane.
- Parameters
-
[in] _normal The plane normal [in] _size Size of the plane [in] _offset Offset along the normal
◆ Set() [2/2]
|
inline |
Set the plane.
- Parameters
-
[in] _normal The plane normal [in] _offset Offset along the normal
Referenced by Plane< T >::Plane().
◆ Side() [1/2]
|
inline |
The side of the plane a box is on.
- Parameters
-
[in] _box The 3D box to check.
- Returns
- Plane::NEGATIVE_SIDE if the distance from the box to the plane is negative, Plane::POSITIVE_SIDE if the distance from the box to the plane is positive, or Plane::BOTH_SIDE if the box is on the plane.
References Plane< T >::BOTH_SIDE, AxisAlignedBox::Center(), Plane< T >::Distance(), Plane< T >::NEGATIVE_SIDE, Plane< T >::POSITIVE_SIDE, and AxisAlignedBox::Size().
◆ Side() [2/2]
The side of the plane a point is on.
- Parameters
-
[in] _point The 3D point to check.
- Returns
- Plane::NEGATIVE_SIDE if the distance from the point to the plane is negative, Plane::POSITIVE_SIDE if the distance from the point to the plane is positive, or Plane::NO_SIDE if the point is on the plane.
References Plane< T >::Distance(), Plane< T >::NEGATIVE_SIDE, Plane< T >::NO_SIDE, and Plane< T >::POSITIVE_SIDE.
◆ Size() [1/2]
|
inline |
Get the plane size.
◆ Size() [2/2]
|
inline |
Get the plane size.
Referenced by Plane< T >::Intersection().
The documentation for this class was generated from the following file: