Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Polygon Class Reference

A class representing a convex polygon. More...

`#include <PfieldGeometry.h>`

Inheritance diagram for Polygon:

[legend]
Collaboration diagram for Polygon:

[legend]
List of all members.

## Public Member Functions
void | addPoint (const PfVec &p)
| Adds a point to the polygon.
GeometryType | getType () const
| Returns the type of a geometric object.
PfieldGeometricObject * | clone () const
| Clones a polygon.
double | distanceTo (const PfPose &base, const PfVec &pos, PfVec &contact) const
| Computes the distance from the border of the object to a given point.
virtual void | initRadiusOfCollisionCircle ()
| Computes value of the radiusOfCollisionCircle variable.
PfieldGeometricObject * | getAbs (const PfPose &base) const
| Returns a geometric object with absolute coordinates.
virtual void | getPoints (std::vector< PfVec > &points)
| Returns all points of the object.
bool | pointInside (const PfVec &point) const
| Tests if a point is inside the polygon.
void | setAbsoluteFromOther (const PfPose &base, PfieldGeometricObject *other)
| Computes absolute coordinates from a base pose and another, relative polygon.
## Public Attributes
std::vector< PfVec > | pts
| A list of points.

## Detailed Description

A class representing a convex polygon.

Definition at line 168 of file PfieldGeometry.h.

## Member Function Documentation

void Polygon::addPoint | ( | const PfVec & | p | ) | `[inline]`

  | Adds a point to the polygon. Parameters:
  p | The point
Definition at line 177 of file PfieldGeometry.h. References pts. Referenced by Parser::parseGeometricObject().

GeometryType Polygon::getType | ( |  | ) | const`[inline, virtual]`

| Returns the type of a geometric object. Returns: The type Implements PfieldGeometricObject. Definition at line 183 of file PfieldGeometry.h. References GeometryType, and POLYGON.

PfieldGeometricObject * Polygon::clone | ( |  | ) | const`[virtual]`

| Clones a polygon. Returns: A pointer to a copy of the object Implements PfieldGeometricObject. Definition at line 583 of file PfieldGeometry.cpp. References PfieldGeometricObject::intersectable, PfieldGeometricObject::position, pts, and PfieldGeometricObject::radiusOfCollisionCircle. Referenced by getAbs().

double Polygon::distanceTo | ( | const PfPose & | base,
|  | const PfVec & | pos,
|  | PfVec & | contact
| ) | const`[virtual]`

  | Computes the distance from the border of the object to a given point. Parameters:
  base | The pose of the object to which the geometric object is assigned
  pos | The tested point
  contact | Returns the next position of the geometric object to the point
Returns: The distance Implements PfieldGeometricObject. Definition at line 472 of file PfieldGeometry.cpp. References PfVec::distanceTo(), pointInside(), pointPerpendicularToLine(), PfPose::pos, pts, PfVec::rotate(), and PfPose::rotation. Referenced by SingleFormation::getPosition().

Here is the call graph for this function:

void Polygon::initRadiusOfCollisionCircle | ( |  | ) | `[virtual]`

| Computes value of the radiusOfCollisionCircle variable. Implements PfieldGeometricObject. Definition at line 515 of file PfieldGeometry.cpp. References pts. Referenced by Parser::parseGeometricObject(), AmongFormation::updateGeometry(), and BetweenFormation::updateGeometry().

PfieldGeometricObject * Polygon::getAbs | ( | const PfPose & | base | ) | const`[virtual]`

  | Returns a geometric object with absolute coordinates. Parameters:
  base | The pose of the object
Returns: A pointer to a new geometric object Implements PfieldGeometricObject. Definition at line 557 of file PfieldGeometry.cpp. References clone(), PfPose::pos, pts, and PfPose::rotation.

Here is the call graph for this function:

void Polygon::getPoints | ( | std::vector< PfVec > & | points | ) | `[virtual]`

  | Returns all points of the object. Parameters:
  points | The list of points to which the object's points will be attached
Reimplemented from PfieldGeometricObject. Definition at line 595 of file PfieldGeometry.cpp. References point, and pts.

bool Polygon::pointInside | ( | const PfVec & | point | ) | const

  | Tests if a point is inside the polygon. Parameters:
  point | The point
Returns: true, if the point is inside Definition at line 531 of file PfieldGeometry.cpp. References EPSILON, PfVec::length(), pi2, pts, and PfVec::scalarProduct(). Referenced by distanceTo(), AmongFormation::positionInsideFormation(), and BetweenFormation::positionInsideFormation().

Here is the call graph for this function:

void Polygon::setAbsoluteFromOther | ( | const PfPose & | base,
|  | PfieldGeometricObject * | other
| ) | `[virtual]`

  | Computes absolute coordinates from a base pose and another, relative polygon. Use careful! The other object has to be the same type and the size! Only positions are changed, other members will be ignored! Parameters:
  base | The new absolute position
  other | A relative geometric object
Implements PfieldGeometricObject. Definition at line 570 of file PfieldGeometry.cpp. References PfPose::pos, pts, and PfPose::rotation.

## Member Data Documentation

std::vector<PfVec> Polygon::pts

| A list of points. Definition at line 172 of file PfieldGeometry.h. Referenced by addPoint(), clone(), distanceTo(), getAbs(), getPoints(), initRadiusOfCollisionCircle(), intersectLineAndPolygon(), intersectPolygonAndCircle(), pointInside(), reduceToConvexHullByWrapping(), setAbsoluteFromOther(), AmongFormation::updateGeometry(), and BetweenFormation::updateGeometry().

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

- Tools/PotentialFields/PfieldGeometry.h
- Tools/PotentialFields/PfieldGeometry.cpp