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

# Tools/PotentialFields/PfieldGeometry.cpp File Reference

Implementation of several geometric functions and objects used by potential fields. More...

`#include "PfieldGeometry.h"`

Include dependency graph for PfieldGeometry.cpp:

Go to the source code of this file.

## Functions
bool | pointPerpendicularToLine (const PfVec &l1, const PfVec &l2, const PfVec &p, double &distance, PfVec &perpendicularPoint)
| Determines if a point is perpendicular to a line.
double | theta (const PfVec &p1, const PfVec &p2)
| Only used by reduceToConvexHullByWrapping.
void | reduceToConvexHullByWrapping (Polygon &p)
| Reduces the points of a polygon to its convex hull.
int | ccw (const PfVec &p0, const PfVec &p1, const PfVec &p2)
| Checks if three points are ordered counter clockwise.
bool | testIntersection (const Line &l1, const Line &l2)
void | intersectLineAndLine (const Line &l1, const Line &l2, std::vector< PfVec > &intersections)
| Intersects a line with another line (basic intersection checking has to be done before).
void | intersectLineAndPolygon (const Line &line, const Polygon &poly, std::vector< PfVec > &intersections)
void | intersectLineAndCircle (const Line &line, const Circle &circle, std::vector< PfVec > &intersections)
| Intersects a line with a circle (basic intersection checking has to be done before).
void | intersectPolygonAndCircle (const Polygon &polygon, const Circle &circle, std::vector< PfVec > &intersections)
| Intersects a polygon with a circle (basic intersection checking has to be done before).
void | intersectCircleAndCircle (const Circle &circle1, const Circle &circle2, std::vector< PfVec > &intersections)
| Intersects a circle with a circle (basic intersection checking has to be done before).
void | intersectGeometricObjects (PfieldGeometricObject *g1, PfieldGeometricObject *g2, std::vector< PfVec > &intersections)
| Intersects two geometric objects and returns the intersection points as well as significant points of the second object inside the intersection.

## Detailed Description

Implementation of several geometric functions and objects used by potential fields.

Author:
  Tim Laue

Definition in file PfieldGeometry.cpp.

## Function Documentation

bool pointPerpendicularToLine | ( | const PfVec & | l1,
|  | const PfVec & | l2,
|  | const PfVec & | p,
|  | double & | distance,
|  | PfVec & | perpendicularPoint
| ) | `[inline]`

  | Determines if a point is perpendicular to a line. Parameters:
  l1 | One end of the line
  l2 | The other end of the line
  p | The point
  distance | The distance to the line, if perpendicular
  perpendicularPoint | The point on the line, if perpendicular
Returns: true, if point is perpendicular. Definition at line 14 of file PfieldGeometry.cpp. References PfVec::distanceTo(), EPSILON, PfVec::scalarProduct(), PfVec::x, and PfVec::y. Referenced by Line::distanceTo(), and Polygon::distanceTo().

Here is the call graph for this function:

double theta | ( | const PfVec & | p1,
|  | const PfVec & | p2
| ) | `[inline]`

| Only used by reduceToConvexHullByWrapping. Definition at line 34 of file PfieldGeometry.cpp. References EPSILON, pi_2, PfVec::x, and PfVec::y. Referenced by MotionRatingBehaviorControl::gotoPoint(), reduceToConvexHullByWrapping(), and MotionRatingBehaviorControl::setWalkMotionRequest().

void reduceToConvexHullByWrapping | ( | Polygon & | p | ) |

  | Reduces the points of a polygon to its convex hull. Parameters:
  p | The polygon
Definition at line 61 of file PfieldGeometry.cpp. References pi2, Polygon::pts, and theta(). Referenced by BetweenFormation::updateGeometry(), and AmongFormation::updateGeometry().

Here is the call graph for this function:

int ccw | ( | const PfVec & | p0,
|  | const PfVec & | p1,
|  | const PfVec & | p2
| ) | `[inline]`

| Checks if three points are ordered counter clockwise. Definition at line 105 of file PfieldGeometry.cpp. References PfVec::x, and PfVec::y. Referenced by testIntersection().

bool testIntersection | ( | const Line & | l1,
|  | const Line & | l2
| ) | `[inline]`

| Definition at line 132 of file PfieldGeometry.cpp. References ccw(), Line::p1, and Line::p2. Referenced by intersectLineAndLine().

Here is the call graph for this function:

void intersectLineAndLine | ( | const Line & | l1,
|  | const Line & | l2,
|  | std::vector< PfVec > & | intersections
| ) |

  | Intersects a line with another line (basic intersection checking has to be done before). Parameters:
  l1 | A line
  l2 | Another line
  intersections | The intersections found
Definition at line 139 of file PfieldGeometry.cpp. References Line::p1, Line::p2, testIntersection(), PfVec::x, and PfVec::y. Referenced by intersectGeometricObjects(), and intersectLineAndPolygon().

Here is the call graph for this function:

void intersectLineAndPolygon | ( | const Line & | line,
|  | const Polygon & | poly,
|  | std::vector< PfVec > & | intersections
| ) |

| Definition at line 161 of file PfieldGeometry.cpp. References intersectLineAndLine(), Line::p1, Line::p2, and Polygon::pts. Referenced by intersectGeometricObjects().

Here is the call graph for this function:

void intersectLineAndCircle | ( | const Line & | line,
|  | const Circle & | circle,
|  | std::vector< PfVec > & | intersections
| ) |

  | Intersects a line with a circle (basic intersection checking has to be done before). Parameters:
  line | A line
  circle | A circle
  intersections | The intersections found
Definition at line 175 of file PfieldGeometry.cpp. References Line::p1, Line::p2, PfieldGeometricObject::position, PfieldGeometricObject::radiusOfCollisionCircle, and PfVec::scalarProduct(). Referenced by intersectGeometricObjects(), and intersectPolygonAndCircle().

Here is the call graph for this function:

void intersectPolygonAndCircle | ( | const Polygon & | polygon,
|  | const Circle & | circle,
|  | std::vector< PfVec > & | intersections
| ) |

  | Intersects a polygon with a circle (basic intersection checking has to be done before). Parameters:
  polygon | A polygon
  circle | A circle
  intersections | The intersections found
Definition at line 215 of file PfieldGeometry.cpp. References intersectLineAndCircle(), Line::p1, Line::p2, and Polygon::pts. Referenced by intersectGeometricObjects().

Here is the call graph for this function:

void intersectCircleAndCircle | ( | const Circle & | circle1,
|  | const Circle & | circle2,
|  | std::vector< PfVec > & | intersections
| ) |

  | Intersects a circle with a circle (basic intersection checking has to be done before). Parameters:
  circle1 | A circle
  circle2 | Another circle
  intersections | The intersections found
Definition at line 229 of file PfieldGeometry.cpp. References EPSILON, pi, PfieldGeometricObject::position, Circle::radius, PfVec::x, and PfVec::y. Referenced by intersectGeometricObjects().

void intersectGeometricObjects | ( | PfieldGeometricObject * | g1,
|  | PfieldGeometricObject * | g2,
|  | std::vector< PfVec > & | intersections
| ) |

  | Intersects two geometric objects and returns the intersection points as well as significant points of the second object inside the intersection. Parameters:
  g1 | The first geometric object
  g2 | The second geometric object
  intersections | The intersections
Definition at line 297 of file PfieldGeometry.cpp. References CIRCLE, PfieldGeometricObject::getType(), PfieldGeometricObject::intersectable, intersectCircleAndCircle(), intersectLineAndCircle(), intersectLineAndLine(), intersectLineAndPolygon(), intersectPolygonAndCircle(), PfVec::length(), LINE, NONE, POLYGON, PfieldGeometricObject::position, and PfieldGeometricObject::radiusOfCollisionCircle. Referenced by FutureWorldModelGenerator::getMaxRotationForObject(), and FutureWorldModelGenerator::getMaxTranslationForObject().

Here is the call graph for this function: