Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
bodies::Box Class Reference

Definition of a box. More...

#include <bodies.h>

Inheritance diagram for bodies::Box:
Inheritance graph
[legend]

Public Member Functions

 Box ()
 
 Box (const AABB &aabb)
 
 Box (const shapes::Shape *shape)
 
BodyPtr cloneAt (const Eigen::Isometry3d &pose, double padding, double scale) const override
 Get a clone of this body, but one that is located at the pose pose and has possibly different passing and scaling: padding and scaling. This function is useful to implement thread safety, when bodies need to be moved around. More...
 
void computeBoundingBox (AABB &bbox) const override
 Compute the axis-aligned bounding box for the body, in its current pose. Scaling and padding are accounted for. More...
 
void computeBoundingCylinder (BoundingCylinder &cylinder) const override
 Compute the bounding cylinder for the body, in its current pose. Scaling and padding are accounted for. More...
 
void computeBoundingSphere (BoundingSphere &sphere) const override
 Compute the bounding radius for the body, in its current pose. Scaling and padding are accounted for. More...
 
double computeVolume () const override
 Compute the volume of the body. This method includes changes induced by scaling and padding. More...
 
bool containsPoint (const Eigen::Vector3d &p, bool verbose=false) const override
 Check if a point is inside the body. Surface points are included. More...
 
std::vector< double > getDimensions () const override
 Get the length & width & height (x, y, z) of the box. More...
 
std::vector< double > getScaledDimensions () const override
 Get the dimensions associated to this body (scaled and padded) More...
 
bool intersectsRay (const Eigen::Vector3d &origin, const Eigen::Vector3d &dir, EigenSTL::vector_Vector3d *intersections=nullptr, unsigned int count=0) const override
 Check if a ray intersects the body, and find the set of intersections, in order, along the ray. A maximum number of intersections can be specified as well. If that number is 0, all intersections are returned. Passing dir as a unit vector will result in faster computation. More...
 
bool samplePointInside (random_numbers::RandomNumberGenerator &rng, unsigned int max_attempts, Eigen::Vector3d &result) const override
 Sample a point that is included in the body using a given random number generator. More...
 
void updateInternalData () override
 This function is called every time a change to the body is made, so that intermediate values stored for efficiency reasons are kept up to date. More...
 
 ~Box () override=default
 
- Public Member Functions inherited from bodies::Body
 Body ()
 
BodyPtr cloneAt (const Eigen::Isometry3d &pose) const
 Get a clone of this body, but one that is located at the pose pose. More...
 
bool containsPoint (double x, double y, double z, bool verbose=false) const
 Check if a point is inside the body. More...
 
double getPadding () const
 Retrieve the current padding. More...
 
const Eigen::Isometry3d & getPose () const
 Retrieve the pose of the body. More...
 
double getScale () const
 Retrieve the current scale. More...
 
shapes::ShapeType getType () const
 Get the type of shape this body represents. More...
 
void setDimensions (const shapes::Shape *shape)
 Set the dimensions of the body (from corresponding shape) More...
 
void setDimensionsDirty (const shapes::Shape *shape)
 Set the dimensions of the body (from corresponding shape). More...
 
void setPadding (double padd)
 If constant padding should be added to the body, this method sets the padding. Default is 0.0. More...
 
void setPaddingDirty (double padd)
 If the dimension of the body should be padded, this method sets the pading. More...
 
void setPose (const Eigen::Isometry3d &pose)
 Set the pose of the body. Default is identity. More...
 
void setPoseDirty (const Eigen::Isometry3d &pose)
 Set the pose of the body. More...
 
void setScale (double scale)
 If the dimension of the body should be scaled, this method sets the scale. Default is 1.0. More...
 
void setScaleDirty (double scale)
 If the dimension of the body should be scaled, this method sets the scale. More...
 
virtual ~Body ()=default
 

Protected Member Functions

void useDimensions (const shapes::Shape *shape) override
 Depending on the shape, this function copies the relevant data to the body. More...
 

Protected Attributes

Eigen::Vector3d center_
 
double height2_
 
double height_
 
Eigen::Matrix3d invRot_
 
double length2_
 
double length_
 
Eigen::Vector3d maxCorner_
 The translated, but not rotated max corner. More...
 
Eigen::Vector3d minCorner_
 The translated, but not rotated min corner. More...
 
double radius2_
 
double radiusB_
 
double width2_
 
double width_
 
- Protected Attributes inherited from bodies::Body
double padding_
 The scale that was set for this body. More...
 
Eigen::Isometry3d pose_
 The location of the body (position and orientation) More...
 
double scale_
 The scale that was set for this body. More...
 
shapes::ShapeType type_
 The type of shape this body was constructed from. More...
 

Detailed Description

Definition of a box.

Definition at line 436 of file bodies.h.

Constructor & Destructor Documentation

◆ Box() [1/3]

bodies::Box::Box ( )
inline

Definition at line 439 of file bodies.h.

◆ Box() [2/3]

bodies::Box::Box ( const shapes::Shape shape)
inline

Definition at line 444 of file bodies.h.

◆ Box() [3/3]

bodies::Box::Box ( const AABB aabb)
explicit

Definition at line 745 of file bodies.cpp.

◆ ~Box()

bodies::Box::~Box ( )
overridedefault

Member Function Documentation

◆ cloneAt()

std::shared_ptr< bodies::Body > bodies::Box::cloneAt ( const Eigen::Isometry3d &  pose,
double  padding,
double  scaling 
) const
overridevirtual

Get a clone of this body, but one that is located at the pose pose and has possibly different passing and scaling: padding and scaling. This function is useful to implement thread safety, when bodies need to be moved around.

Implements bodies::Body.

Definition at line 610 of file bodies.cpp.

◆ computeBoundingBox()

void bodies::Box::computeBoundingBox ( AABB bbox) const
overridevirtual

Compute the axis-aligned bounding box for the body, in its current pose. Scaling and padding are accounted for.

Implements bodies::Body.

Definition at line 665 of file bodies.cpp.

◆ computeBoundingCylinder()

void bodies::Box::computeBoundingCylinder ( BoundingCylinder cylinder) const
overridevirtual

Compute the bounding cylinder for the body, in its current pose. Scaling and padding are accounted for.

Implements bodies::Body.

Definition at line 634 of file bodies.cpp.

◆ computeBoundingSphere()

void bodies::Box::computeBoundingSphere ( BoundingSphere sphere) const
overridevirtual

Compute the bounding radius for the body, in its current pose. Scaling and padding are accounted for.

Implements bodies::Body.

Definition at line 628 of file bodies.cpp.

◆ computeVolume()

double bodies::Box::computeVolume ( ) const
overridevirtual

Compute the volume of the body. This method includes changes induced by scaling and padding.

Implements bodies::Body.

Definition at line 623 of file bodies.cpp.

◆ containsPoint()

bool bodies::Box::containsPoint ( const Eigen::Vector3d &  p,
bool  verbose = false 
) const
overridevirtual

Check if a point is inside the body. Surface points are included.

Implements bodies::Body.

Definition at line 558 of file bodies.cpp.

◆ getDimensions()

std::vector< double > bodies::Box::getDimensions ( ) const
overridevirtual

Get the length & width & height (x, y, z) of the box.

Implements bodies::Body.

Definition at line 572 of file bodies.cpp.

◆ getScaledDimensions()

std::vector< double > bodies::Box::getScaledDimensions ( ) const
overridevirtual

Get the dimensions associated to this body (scaled and padded)

Implements bodies::Body.

Definition at line 577 of file bodies.cpp.

◆ intersectsRay()

bool bodies::Box::intersectsRay ( const Eigen::Vector3d &  origin,
const Eigen::Vector3d &  dir,
EigenSTL::vector_Vector3d *  intersections = nullptr,
unsigned int  count = 0 
) const
overridevirtual

Check if a ray intersects the body, and find the set of intersections, in order, along the ray. A maximum number of intersections can be specified as well. If that number is 0, all intersections are returned. Passing dir as a unit vector will result in faster computation.

Implements bodies::Body.

Definition at line 672 of file bodies.cpp.

◆ samplePointInside()

bool bodies::Box::samplePointInside ( random_numbers::RandomNumberGenerator rng,
unsigned int  max_attempts,
Eigen::Vector3d &  result 
) const
overridevirtual

Sample a point that is included in the body using a given random number generator.

Sometimes multiple attempts need to be generated. The function terminates with failure (returns false) after max_attempts attempts. If the call is successful (returns true) the point is written to result

Reimplemented from bodies::Body.

Definition at line 550 of file bodies.cpp.

◆ updateInternalData()

void bodies::Box::updateInternalData ( )
overridevirtual

This function is called every time a change to the body is made, so that intermediate values stored for efficiency reasons are kept up to date.

Implements bodies::Body.

Definition at line 582 of file bodies.cpp.

◆ useDimensions()

void bodies::Box::useDimensions ( const shapes::Shape shape)
overrideprotectedvirtual

Depending on the shape, this function copies the relevant data to the body.

Implements bodies::Body.

Definition at line 564 of file bodies.cpp.

Member Data Documentation

◆ center_

Eigen::Vector3d bodies::Box::center_
protected

Definition at line 481 of file bodies.h.

◆ height2_

double bodies::Box::height2_
protected

Definition at line 489 of file bodies.h.

◆ height_

double bodies::Box::height_
protected

Definition at line 478 of file bodies.h.

◆ invRot_

Eigen::Matrix3d bodies::Box::invRot_
protected

Definition at line 482 of file bodies.h.

◆ length2_

double bodies::Box::length2_
protected

Definition at line 487 of file bodies.h.

◆ length_

double bodies::Box::length_
protected

Definition at line 476 of file bodies.h.

◆ maxCorner_

Eigen::Vector3d bodies::Box::maxCorner_
protected

The translated, but not rotated max corner.

Definition at line 485 of file bodies.h.

◆ minCorner_

Eigen::Vector3d bodies::Box::minCorner_
protected

The translated, but not rotated min corner.

Definition at line 484 of file bodies.h.

◆ radius2_

double bodies::Box::radius2_
protected

Definition at line 491 of file bodies.h.

◆ radiusB_

double bodies::Box::radiusB_
protected

Definition at line 490 of file bodies.h.

◆ width2_

double bodies::Box::width2_
protected

Definition at line 488 of file bodies.h.

◆ width_

double bodies::Box::width_
protected

Definition at line 477 of file bodies.h.


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


geometric_shapes
Author(s): Ioan Sucan , Gil Jones
autogenerated on Sun Aug 22 2021 02:42:26