Gazebo Math

API Reference

8.1.0
Plane< T > Class Template Reference

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.
 
 Plane (const Vector3< T > &_normal, const Vector2< T > &_size, T _offset)
 Constructor.
 
 Plane (const Vector3< T > &_normal, T _offset=0.0)
 Constructor from a normal and a distance.
 
Distance (const Vector3< T > &_origin, const Vector3< T > &_dir) const
 Get distance to the plane give an origin and direction.
 
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.
 
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.
 
Vector3< T > & Normal ()
 Get the plane normal.
 
const Vector3< T > & Normal () const
 Get the plane normal.
 
Offset () const
 Get the plane offset.
 
void Set (const Vector3< T > &_normal, const Vector2< T > &_size, T _offset)
 Set the plane.
 
void Set (const Vector3< T > &_normal, T _offset)
 Set the plane.
 
PlaneSide Side (const math::AxisAlignedBox &_box) const
 The side of the plane a box is on.
 
PlaneSide Side (const Vector3< T > &_point) const
 The side of the plane a point is on.
 
Vector2< T > & Size ()
 Get the plane size.
 
const Vector2< T > & Size () const
 Get the plane size.
 

Detailed Description

template<typename T>
class gz::math::Plane< T >

A plane and related functions.

Member Enumeration Documentation

◆ PlaneSide

template<typename T >
enum PlaneSide

Enum used to indicate a side of the plane, no side, or both sides for entities on the plane.

See also
Side
Enumerator
NEGATIVE_SIDE 

Negative side of the plane. This is the side that is opposite the normal.

POSITIVE_SIDE 

Positive side of the plane. This is the side that has the normal vector.

NO_SIDE 

On the plane.

BOTH_SIDE 

On both sides of the plane.

Constructor & Destructor Documentation

◆ Plane() [1/3]

template<typename T >
Plane ( )
inline

Constructor.

◆ Plane() [2/3]

template<typename T >
Plane ( const Vector3< T > &  _normal,
_offset = 0.0 
)
inlineexplicit

Constructor from a normal and a distance.

Parameters
[in]_normalThe plane normal
[in]_offsetOffset along the normal

◆ Plane() [3/3]

template<typename T >
Plane ( const Vector3< T > &  _normal,
const Vector2< T > &  _size,
_offset 
)
inline

Constructor.

Parameters
[in]_normalThe plane normal
[in]_sizeSize of the plane
[in]_offsetOffset along the normal

References Plane< T >::Set().

Member Function Documentation

◆ Distance() [1/2]

template<typename T >
T Distance ( const Vector3< T > &  _origin,
const Vector3< T > &  _dir 
) const
inline

Get distance to the plane give an origin and direction.

Parameters
[in]_originthe origin
[in]_dira direction
Returns
the shortest distance

◆ Distance() [2/2]

template<typename T >
T Distance ( const Vector3< T > &  _point) const
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]_point3D point to calculate distance from.
Returns
Distance from the point to the plane.
See also
Side

Referenced by Plane< T >::Side(), and Plane< T >::Side().

◆ Intersection()

template<typename T >
std::optional< Vector3< T > > Intersection ( const Vector3< T > &  _point,
const Vector3< T > &  _gradient,
const double _tolerance = 1e-6 
) const
inline

Get the intersection of an infinite line with the plane, given the line's gradient and a point in parametrized space.

Parameters
[in]_pointA point that lies on the line.
[in]_gradientThe gradient of the line.
[in]_toleranceThe 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]

template<typename T >
Vector3< T > & Normal ( )
inline

Get the plane normal.

◆ Normal() [2/2]

template<typename T >
const Vector3< T > & Normal ( ) const
inline

Get the plane normal.

Referenced by Plane< T >::Intersection().

◆ Offset()

template<typename T >
T Offset ( ) const
inline

Get the plane offset.

Referenced by Plane< T >::Intersection().

◆ Set() [1/2]

template<typename T >
void Set ( const Vector3< T > &  _normal,
const Vector2< T > &  _size,
_offset 
)
inline

Set the plane.

Parameters
[in]_normalThe plane normal
[in]_sizeSize of the plane
[in]_offsetOffset along the normal

◆ Set() [2/2]

template<typename T >
void Set ( const Vector3< T > &  _normal,
_offset 
)
inline

Set the plane.

Parameters
[in]_normalThe plane normal
[in]_offsetOffset along the normal

Referenced by Plane< T >::Plane().

◆ Side() [1/2]

template<typename T >
PlaneSide Side ( const math::AxisAlignedBox _box) const
inline

The side of the plane a box is on.

Parameters
[in]_boxThe 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, and Plane< T >::POSITIVE_SIDE.

◆ Side() [2/2]

template<typename T >
PlaneSide Side ( const Vector3< T > &  _point) const
inline

The side of the plane a point is on.

Parameters
[in]_pointThe 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]

template<typename T >
Vector2< T > & Size ( )
inline

Get the plane size.

◆ Size() [2/2]

template<typename T >
const Vector2< T > & Size ( ) const
inline

Get the plane size.

Referenced by Plane< T >::Intersection().


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