47 #include "mengeCommon.h"
91 inline const Vector2 midPt()
const {
return _point + ( 0.5f * _length) * _unitDir; }
114 NearTypeEnum distanceSqToPoint(
const Vector2 & pt,
Vector2 & nearPt,
float & distSq )
const;
126 float circleIntersection(
const Vector2 & dir,
const Vector2 & start,
float radius )
const;
133 inline float length()
const {
return _length; }
141 bool pointOnObstacle(
const Vector2 & pt )
const;
154 inline bool pointOutside(
const Vector2 & point )
const {
return _doubleSided || ( leftOf( _point, getP1(), point ) < 0.f ); }
166 inline bool p0Convex(
bool agtOnRight)
const {
return agtOnRight ? _isConvex : _doubleSided && !_isConvex; }
180 inline bool p1Convex(
bool agtOnRight)
const {
return _nextObstacle == 0x0 ?
true : ( agtOnRight ? _nextObstacle->_isConvex : _doubleSided && _nextObstacle->_isConvex ); }
255 inline MENGE_API
float distSqPointLineSegment(
const Vector2& a,
const Vector2& b,
258 const float r = ((c - a) * (b - a)) / absSq(b - a);
262 }
else if (r > 1.0f) {
265 return absSq(c - (a + r * (b - a)));
size_t _id
A unique identifier for this obstacle.
Definition: Obstacle.h:237
size_t _class
The class of obstacle, used so agents can ignore/include obstacles.
Definition: Obstacle.h:242
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
Vector2 normal() const
Retrieves the normal of the obstacle.
Definition: Obstacle.h:81
Obstacle * _prevObstacle
Pointer to the previous obstacle in the greater obstacle structure. If the obstacle is open...
Definition: Obstacle.h:222
void setClosedState(bool closed)
Sets the obstacle's closed state.
Definition: Obstacle.h:191
const Obstacle * next() const
Returns the next obstacle in sequence.
Definition: Obstacle.h:101
float length() const
Returns the length of the obstacle.
Definition: Obstacle.h:133
float _length
The distance in the direction the obstacle extends.
Definition: Obstacle.h:232
Obstacle * _nextObstacle
Pointer to the next obstacle in the greater obstacle structure. If the obstacle is open...
Definition: Obstacle.h:211
bool p0Convex(bool agtOnRight) const
Reports if the obstacle is convext at _point.
Definition: Obstacle.h:166
Vector2 _unitDir
The direction the obstacle extends from the originating point.
Definition: Obstacle.h:227
Vector2 _point
The point from which the obstacle is defined.
Definition: Obstacle.h:216
const Vector2 & getP0() const
Retrieve the first point on the obstacle.
Definition: Obstacle.h:86
Defines static obstacles in the simulation.
Definition: Obstacle.h:56
const Vector2 midPt() const
Retrieve the obstacle's mid-point.
Definition: Obstacle.h:91
bool p1Convex(bool agtOnRight) const
Reports if the obstacle is convext at _point + _length * _unitDir.
Definition: Obstacle.h:180
NearTypeEnum
An enumeration to define the type of nearest point - first, middle, last.
Definition: Obstacle.h:61
The namespace that contains the basic simulation mechanisms.
bool _doubleSided
Reports if the obstacle is double sided.
Definition: Obstacle.h:199
bool _isConvex
Reports if the obstacle is convex around the obstacle's point (_point).
Definition: Obstacle.h:205
bool pointOutside(const Vector2 &point) const
Reports if the given point is on the "outside" of the obstacle. This definition depends on whether th...
Definition: Obstacle.h:154