Gazebo Math

API Reference

7.5.1
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. 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...
 
Distance (const Vector3< T > &_origin, const Vector3< T > &_dir) const
 Get distance to the plane give an origin and direction. More...
 
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...
 
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
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/4]

Plane ( )
inline

Constructor.

◆ Plane() [2/4]

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/4]

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().

◆ Plane() [4/4]

Plane ( const Plane< T > &  _plane)
default

Copy constructor.

Parameters
[in]_planePlane to copy

◆ ~Plane()

~Plane ( )
default

Destructor.

Member Function Documentation

◆ Distance() [1/2]

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

References Vector3< T >::Dot().

◆ Distance() [2/2]

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().

◆ Intersection()

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]

Vector3<T>& Normal ( )
inline

Get the plane normal.

◆ Normal() [2/2]

const Vector3<T>& Normal ( ) const
inline

Get the plane normal.

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

◆ Offset()

T Offset ( ) const
inline

Get the plane offset.

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

◆ operator=()

Plane<T>& operator= ( const Plane< T > &  _p)
default

Equal operator.

Parameters
_panother plane
Returns
itself

◆ Set() [1/2]

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]

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]

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, Plane< T >::POSITIVE_SIDE, and AxisAlignedBox::Size().

◆ Side() [2/2]

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]

Vector2<T>& Size ( )
inline

Get the plane size.

◆ Size() [2/2]

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: