Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Public Attributes | List of all members
Menge::Agents::Obstacle Class Reference

Defines static obstacles in the simulation. More...

#include <Obstacle.h>

Inheritance diagram for Menge::Agents::Obstacle:
Menge::NavMeshObstacle

Public Types

enum  NearTypeEnum { FIRST, MIDDLE, LAST }
 An enumeration to define the type of nearest point - first, middle, last.
 

Public Member Functions

 Obstacle ()
 Constructs a static obstacle instance.
 
 ~Obstacle ()
 Destroys this static obstacle instance.
 
Vector2 normal () const
 Retrieves the normal of the obstacle. More...
 
const Vector2getP0 () const
 Retrieve the first point on the obstacle.
 
const Vector2 midPt () const
 Retrieve the obstacle's mid-point.
 
Vector2 getP1 () const
 Retrieve the second point on the obstacle.
 
const Obstaclenext () const
 Returns the next obstacle in sequence.
 
NearTypeEnum distanceSqToPoint (const Vector2 &pt, Vector2 &nearPt, float &distSq) const
 Computes the squared distance from the obstacle to the given point. Also sets the value of the point in the provided Vector2. More...
 
float circleIntersection (const Vector2 &dir, const Vector2 &start, float radius) const
 Determines if a circle, moving along a ray, will intersect the obstacle. More...
 
float length () const
 Returns the length of the obstacle. More...
 
bool pointOnObstacle (const Vector2 &pt) const
 Reports if the given point lies on the obstacle. More...
 
bool pointOutside (const Vector2 &point) const
 Reports if the given point is on the "outside" of the obstacle. This definition depends on whether the obstacle is double-sided or not. More...
 
bool p0Convex (bool agtOnRight) const
 Reports if the obstacle is convext at _point. More...
 
bool p1Convex (bool agtOnRight) const
 Reports if the obstacle is convext at _point + _length * _unitDir. More...
 
void setClosedState (bool closed)
 Sets the obstacle's closed state. More...
 

Public Attributes

bool _doubleSided
 Reports if the obstacle is double sided. More...
 
bool _isConvex
 Reports if the obstacle is convex around the obstacle's point (_point).
 
Obstacle_nextObstacle
 Pointer to the next obstacle in the greater obstacle structure. If the obstacle is open, it could be NULL.
 
Vector2 _point
 The point from which the obstacle is defined.
 
Obstacle_prevObstacle
 Pointer to the previous obstacle in the greater obstacle structure. If the obstacle is open, it could be NULL.
 
Vector2 _unitDir
 The direction the obstacle extends from the originating point.
 
float _length
 The distance in the direction the obstacle extends.
 
size_t _id
 A unique identifier for this obstacle.
 
size_t _class
 The class of obstacle, used so agents can ignore/include obstacles.
 

Detailed Description

Defines static obstacles in the simulation.

Member Function Documentation

float Menge::Agents::Obstacle::circleIntersection ( const Vector2 dir,
const Vector2 start,
float  radius 
) const

Determines if a circle, moving along a ray, will intersect the obstacle.

Parameters
dirThe direction of motion
startThe starting point of the circle
radiusThe radius of the circle
Returns
The time to collision (a large value representing infinity if no collision is possible.)
Obstacle::NearTypeEnum Menge::Agents::Obstacle::distanceSqToPoint ( const Vector2 pt,
Vector2 nearPt,
float &  distSq 
) const

Computes the squared distance from the obstacle to the given point. Also sets the value of the point in the provided Vector2.

Parameters
ptThe point whose distance is to be evaluated
nearPtThe position on the obstacle which is nearest to the test point will be set here.
distSqThe squared distance to the line (i.e. ||pt - nearPt||^2) is placed inside this parameter.
Returns
The classificaiton of what the nearest point is - first, middle, or last
float Menge::Agents::Obstacle::length ( ) const
inline

Returns the length of the obstacle.

Returns
The length.
Vector2 Menge::Agents::Obstacle::normal ( ) const
inline

Retrieves the normal of the obstacle.

Returns
The normal
bool Menge::Agents::Obstacle::p0Convex ( bool  agtOnRight) const
inline

Reports if the obstacle is convext at _point.

Takes into account the double-sidedness of the obstacle and the side of the obstacle the agent is on.

Parameters
agtOnRightIndicate if the agent is on the right side of the obstacle (true) or the left (false).
Returns
True if the obstacle is convex, false otherwise.
bool Menge::Agents::Obstacle::p1Convex ( bool  agtOnRight) const
inline

Reports if the obstacle is convext at _point + _length * _unitDir.

Takes into account the double-sidedness of the obstacle and the side of the obstacle the agent is on.

Parameters
agtOnRightIndicate if the agent is on the right side of the obstacle (true) or the left (false).
Returns
True if the obstacle is convex, false otherwise.
bool Menge::Agents::Obstacle::pointOnObstacle ( const Vector2 pt) const

Reports if the given point lies on the obstacle.

Parameters
ptThe point to test
Returns
True if pt is on the obstacle, false otherwise
bool Menge::Agents::Obstacle::pointOutside ( const Vector2 point) const
inline

Reports if the given point is on the "outside" of the obstacle. This definition depends on whether the obstacle is double-sided or not.

Parameters
pointThe point to test.
Returns
A boolean reporting if the point lies on the outside of this obstacle (true) or not (false).
void Menge::Agents::Obstacle::setClosedState ( bool  closed)
inline

Sets the obstacle's closed state.

If closed, it is part of a sequence of obstacles that form a closed polygon. If open, it is part of a polyline.

Parameters
closedDefines the obstacle as part of a closed polygon (true), or a closed polygon (false).

Member Data Documentation

bool Menge::Agents::Obstacle::_doubleSided

Reports if the obstacle is double sided.

If double sided (true) then the obstacle should be included in the nearby obstacles, regardless of which side of the line the agent lies.


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