Menge Plugin Examples
A Collection of Example Plugins for the Menge Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Ellipse.h
Go to the documentation of this file.
1 
6 #ifndef __ELLIPSE_H__
7 #define __ELLIPSE_H__
8 
9 #include "mengeCommon.h"
10 
11 // forward declarations
12 namespace Menge {
13  namespace Agents {
14  class Obstacle;
15  }
16 }
17 using namespace Menge;
18 
19 namespace GCF {
20 
24  class Ellipse {
25  public:
31  Ellipse();
32 
38  Ellipse( const Vector2 & center );
39 
47  Ellipse( const Vector2 & center, const Vector2 & axes );
48 
59  Ellipse( const Vector2 & center, const Vector2 & axes, float angle );
60 
68  inline float ellipseCenterDistance( const Ellipse & other ) const { return abs( other._center - _center ); }
69 
77  inline Vector2 ellipseCenterDisplace( const Ellipse & other ) const { return _center - other._center; }
78 
86  float distanceOfClosestApproach( const Ellipse & other ) const;
87 
98  float approxDistanceOfClosestApproach( const Ellipse & other ) const;
99 
107  Vector2 closestPoint( const Vector2 & pt ) const;
108 
121  float minimumDistance( const Agents::Obstacle * obstacle, Vector2 & dir ) const;
122 
134  float distanceOfClosestApproach( const Agents::Obstacle * line ) const;
135 
149  float approximateMinimumDistance( const Vector2 & pt ) const;
150 
160  float radiusInPointDirection( const Vector2 & pt ) const;
161 
170  Vector2 toEllipseSpace( const Vector2 & pt ) const;
171 
179  Vector2 fromEllipseSpace( const Vector2 & pt ) const;
180 
186  inline void setOrientation( float angle ) { _cosPhi = cos(angle); _sinPhi = sin(angle); }
187 
193  inline void setOrientation( const Vector2 & dir ) { _cosPhi = dir.x(); _sinPhi = dir.y(); }
194 
200  inline void setCenter( const Vector2 & pos ) { _center.set( pos ); }
201 
208  inline void setAxes( const Vector2 & axes ) { _majorAxis = axes.x(); _minorAxis = axes.y(); }
209 
216  inline void setAxes( float major, float minor ) { _majorAxis = major; _minorAxis = minor; }
217 
223  inline void setMajorAxis( float length ) { _majorAxis = length; }
224 
230  inline float getMajor() const { return _majorAxis; }
231 
237  inline void setMinorAxis( float length ) { _minorAxis = length; }
238 
244  inline float getMinor() const { return _minorAxis; }
245 
249  inline float getSmallerAxis() const { return _minorAxis < _majorAxis ? _minorAxis : _majorAxis; }
250 
254  inline float getLargerAxis() const { return _minorAxis < _majorAxis ? _majorAxis : _minorAxis; }
255 
256  protected:
260  Vector2 _center;
261 
267  float _cosPhi;
268 
274  float _sinPhi;
275 
285  float _majorAxis;
286 
296  float _minorAxis;
297  };
298 } // namespace GCF
299 #endif //__ELLIPSE_H__
Contains the specification of the generalized centrifugal force pedestrian model. ...
Definition: Ellipse.cpp:9
float _sinPhi
Part of the orientation of the ellipse. Oriented with angle phi. This is sine of that angle...
Definition: Ellipse.h:274
void setAxes(const Vector2 &axes)
Sets the major and minor axes of the ellipse.
Definition: Ellipse.h:208
float getMajor() const
Returns the length of the major axis.
Definition: Ellipse.h:230
float _minorAxis
Length of semi-minor axis. The semi-minor axis is perpendicular to the "direction" the ellipse is ori...
Definition: Ellipse.h:296
float _cosPhi
Part of the orientation of the ellipse. Oriented with angle phi. This is cosine of that angle...
Definition: Ellipse.h:267
float ellipseCenterDistance(const Ellipse &other) const
Compute the distance between the centers of this ellipse and the provided ellipse.
Definition: Ellipse.h:68
void setMajorAxis(float length)
Sets the major axis of the ellipse.
Definition: Ellipse.h:223
void setMinorAxis(float length)
Sets the minor axis of the ellipse.
Definition: Ellipse.h:237
Vector2 ellipseCenterDisplace(const Ellipse &other) const
Computes the displacement from this ellipse's center to the other ellipse's center.
Definition: Ellipse.h:77
Definition of an ellipse.
Definition: Ellipse.h:24
void setAxes(float major, float minor)
Sets the major and minor axes of the ellipse.
Definition: Ellipse.h:216
void setOrientation(const Vector2 &dir)
Sets the orientation of the ellipse.
Definition: Ellipse.h:193
Vector2 _center
The center of the ellipse.
Definition: Ellipse.h:260
float getLargerAxis() const
Returns the larger of the axes.
Definition: Ellipse.h:254
float getMinor() const
Returns the length of the minor axis.
Definition: Ellipse.h:244
float _majorAxis
Length of semi-major axis. The semi-major axis is the "direction" the ellipse is oriented. So, when phi is zero, the semi-major axis is aligned with the x-axis. It need not be a bigger value than the semi-minor axis.
Definition: Ellipse.h:285
float getSmallerAxis() const
Returns the smaller of the axes.
Definition: Ellipse.h:249
void setOrientation(float angle)
Sets the orientation of the ellipse.
Definition: Ellipse.h:186
void setCenter(const Vector2 &pos)
Set center of the ellipse.
Definition: Ellipse.h:200