Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

ConvexPolyObstacle Class Reference

Manages collision detection with convex polygons. More...

#include <PlannerObstacles.h>

Inheritance diagram for ConvexPolyObstacle:

Detailed Description

Manages collision detection with convex polygons.

Basically the same algorithm used for rectangles, just generalized for more sides

Definition at line 501 of file PlannerObstacles.h.

List of all members.

Public Member Functions

 ConvexPolyObstacle ()
 the 'outside' normal of segment following corresponding entry in points
ConvexPolyObstacleoperator= (const ConvexPolyObstacle &o)
 Assignment, should not use plist::Dictionary version.
const std::vector
< fmat::Column< 2 > > & 
getPoints () const
 returns the points, in counter-clockwise order
const std::vector
< fmat::Column< 2 > > & 
getNormals () const
 returns the normals, in counter-clockwise order
void hull (const std::set< fmat::Column< 2 > > &p)
 Selects points which form a convex hull, clears current points.
void clear ()
 remove all points and normals
void addPoint (const fmat::Column< 2 > &p)
 Add a point to the polygon, must maintain convexity and in counter-clockwise order, call close() when done.
void close ()
 Calculates values for final segment of polygon, call after a series of addPoint().
virtual bool collides (const fmat::SubVector< 2, const fmat::fmatReal > &point) const
 Test if the polygon includes a specific point.
bool collides (const RectangularObstacle &other) const
 For polygon on rectangle collision.
bool collides (const CircularObstacle &other) const
 For polygon on circle collision.
bool collides (const ConvexPolyObstacle &other) const
 For polygon on polygon collision.
virtual fmat::Column< 2 > getSupport (const fmat::SubVector< 2, const fmat::fmatReal > &direction) const
virtual fmat::Column< 2 > getCenter () const
 get center point of obstacle
virtual void updatePosition (const fmat::SubVector< 2, const fmat::fmatReal > &newPos)
virtual void rotate (const fmat::SubVector< 2, const fmat::fmatReal > &origin, const fmat::SubMatrix< 2, 2, const fmat::fmatReal > &rot)
virtual BoundingBox2D getBoundingBox () const
 get boundaries of the current obstacle
virtual void offset (const fmat::Column< 2 > &off)
virtual fmat::Column< 2 > gradient (const fmat::SubVector< 2, const fmat::fmatReal > &pt) const
virtual std::string toString () const
 return current value as a string
virtual void loadXML (xmlNode *node)
 This specialization looks for the SensorInfo::sensorType, then has the factory construct the correct subtype before loading the node into and returning that.
virtual void saveXML (xmlNode *node) const
 subclasses are expected to provide a working implementation
virtual ConvexPolyObstacleclone () const __attribute__((warn_unused_result))
 clone definition for ConvexPolyObstacle

Protected Attributes

std::vector< fmat::Column< 2 > > points
std::vector< fmat::Column< 2 > > normals
 the points of the polygon, in counter-clockwise order

Static Protected Attributes

static const std::string autoRegisterName = PlannerObstacle2D::getRegistry().registerType<ConvexPolyObstacle>("ConvexPoly")
 stores the class name used for polymorphic load/save

Constructor & Destructor Documentation

ConvexPolyObstacle::ConvexPolyObstacle (  ) 

the 'outside' normal of segment following corresponding entry in points

default constructor

Definition at line 511 of file PlannerObstacles.h.


Member Function Documentation

void ConvexPolyObstacle::addPoint ( const fmat::Column< 2 > &  p  ) 

Add a point to the polygon, must maintain convexity and in counter-clockwise order, call close() when done.

Definition at line 658 of file PlannerObstacles.cc.

Referenced by rotate().

void ConvexPolyObstacle::clear (  )  [virtual]

remove all points and normals

Reimplemented from plist::DictionaryBase.

Definition at line 536 of file PlannerObstacles.h.

Referenced by rotate().

ConvexPolyObstacle * ConvexPolyObstacle::clone (  )  const [virtual]

clone definition for ConvexPolyObstacle

Reimplemented from plist::DictionaryOf< PO, Alloc >.

Definition at line 20 of file PlannerObstacles.cc.

void ConvexPolyObstacle::close (  ) 

Calculates values for final segment of polygon, call after a series of addPoint().

Definition at line 671 of file PlannerObstacles.cc.

Referenced by rotate().

bool ConvexPolyObstacle::collides ( const ConvexPolyObstacle other  )  const

For polygon on polygon collision.

Definition at line 758 of file PlannerObstacles.cc.

bool ConvexPolyObstacle::collides ( const CircularObstacle other  )  const

For polygon on circle collision.

Definition at line 716 of file PlannerObstacles.cc.

bool ConvexPolyObstacle::collides ( const RectangularObstacle other  )  const

For polygon on rectangle collision.

Definition at line 689 of file PlannerObstacles.cc.

bool ConvexPolyObstacle::collides ( const fmat::SubVector< 2, const fmat::fmatReal > &  point  )  const [virtual]

Test if the polygon includes a specific point.

Definition at line 679 of file PlannerObstacles.cc.

Referenced by GaitedFootsteps::expand().

BoundingBox2D ConvexPolyObstacle::getBoundingBox (  )  const [virtual]

get boundaries of the current obstacle

Implements PlannerObstacle< N >.

Definition at line 820 of file PlannerObstacles.cc.

fmat::Column< 2 > ConvexPolyObstacle::getCenter (  )  const [virtual]

get center point of obstacle

Implements PlannerObstacle< N >.

Definition at line 801 of file PlannerObstacles.cc.

Referenced by updatePosition().

const std::vector<fmat::Column<2> >& ConvexPolyObstacle::getNormals (  )  const

returns the normals, in counter-clockwise order

Definition at line 525 of file PlannerObstacles.h.

const std::vector<fmat::Column<2> >& ConvexPolyObstacle::getPoints (  )  const

returns the points, in counter-clockwise order

Definition at line 522 of file PlannerObstacles.h.

fmat::Column< 2 > ConvexPolyObstacle::getSupport ( const fmat::SubVector< 2, const fmat::fmatReal > &  direction  )  const [virtual]

Definition at line 787 of file PlannerObstacles.cc.

fmat::Column< 2 > ConvexPolyObstacle::gradient ( const fmat::SubVector< 2, const fmat::fmatReal > &  pt  )  const [virtual]

Definition at line 833 of file PlannerObstacles.cc.

void ConvexPolyObstacle::hull ( const std::set< fmat::Column< 2 > > &  p  ) 

Selects points which form a convex hull, clears current points.

Passing a set because the hulling algorithm (Andrew's Monotone Chain) begins with sorting the list of points anyway. If you have a different STL container 'c' just pass std::set<fmat::Column<2>(c.begin(),c.end()) to convert to a set. This implementation adapted from: http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain

Definition at line 628 of file PlannerObstacles.cc.

Referenced by GaitedFootsteps::expand().

void ConvexPolyObstacle::loadXML ( xmlNode node  )  [virtual]

This specialization looks for the SensorInfo::sensorType, then has the factory construct the correct subtype before loading the node into and returning that.

From the name of node, will instantiate a new ObjectBase subclass to load it.

supports use of plist::ArrayOf<PlannerObstacle> for polymorphic load/save

The mapping from node names to actual instantiated types is:

If successful, returns a pointer to a newly allocated region, which the caller is responsible for freeing. If an error occurs, NULL is returned.

attempts to load a new T instance from the specified xmlNode

Reimplemented from plist::DictionaryBase.

Definition at line 886 of file PlannerObstacles.cc.

void ConvexPolyObstacle::offset ( const fmat::Column< 2 > &  off  )  [virtual]

Definition at line 827 of file PlannerObstacles.cc.

Referenced by updatePosition().

ConvexPolyObstacle& ConvexPolyObstacle::operator= ( const ConvexPolyObstacle o  ) 

Assignment, should not use plist::Dictionary version.

Definition at line 514 of file PlannerObstacles.h.

void ConvexPolyObstacle::rotate ( const fmat::SubVector< 2, const fmat::fmatReal > &  origin,
const fmat::SubMatrix< 2, 2, const fmat::fmatReal > &  rot 
) [virtual]

Definition at line 810 of file PlannerObstacles.cc.

void ConvexPolyObstacle::saveXML ( xmlNode node  )  const [virtual]

subclasses are expected to provide a working implementation

Reimplemented from plist::DictionaryBase.

Definition at line 897 of file PlannerObstacles.cc.

std::string ConvexPolyObstacle::toString (  )  const [virtual]

return current value as a string

Reimplemented from PlannerObstacle< N >.

Definition at line 879 of file PlannerObstacles.cc.

virtual void ConvexPolyObstacle::updatePosition ( const fmat::SubVector< 2, const fmat::fmatReal > &  newPos  )  [virtual]

Definition at line 557 of file PlannerObstacles.h.


Member Data Documentation

const std::string ConvexPolyObstacle::autoRegisterName = PlannerObstacle2D::getRegistry().registerType<ConvexPolyObstacle>("ConvexPoly") [static, protected]

stores the class name used for polymorphic load/save

Definition at line 504 of file PlannerObstacles.h.

std::vector<fmat::Column<2> > ConvexPolyObstacle::normals [protected]

the points of the polygon, in counter-clockwise order

Definition at line 507 of file PlannerObstacles.h.

Referenced by addPoint(), clear(), close(), collides(), getNormals(), gradient(), hull(), operator=(), and toString().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:06 2016 by Doxygen 1.6.3