24 #ifndef BASE_TOOLS2D_H 25 #define BASE_TOOLS2D_H 57 inline bool operator== (
const Vector2d &v)
const;
68 inline Vector2d& operator/= (
double c);
71 inline bool IsNull(
double tolerance = 0.0)
const;
72 inline double Length(
void)
const;
73 inline double Angle(
void)
const;
74 inline double Sqr(
void)
const;
76 inline Vector2d& Set(
double x,
double y);
78 inline Vector2d& Scale(
double factor);
79 inline Vector2d& Rotate(
double angle);
82 inline Vector2d Perpendicular(
bool clockwise =
false)
const;
83 static inline Vector2d FromPolar(
double r,
double fi);
86 inline bool IsEqual(
const Vector2d &v,
double tolerance = 0.0)
const;
88 double GetAngle(
const Vector2d &v)
const;
104 inline BoundBox2d (
double fX1,
double fY1,
double fX2,
double fY2);
105 inline bool IsValid (
void);
106 inline bool IsEqual(
const BoundBox2d&,
double tolerance)
const;
110 inline bool operator== (
const BoundBox2d& rclBB)
const;
113 inline double Width(
void)
const;
114 inline double Height(
void)
const;
115 inline bool Contains(
const Vector2d &v)
const;
116 inline bool Contains(
const Vector2d &v,
double tolerance)
const;
117 inline Vector2d GetCenter(
void)
const;
119 inline void SetVoid(
void);
122 bool Intersect(
const Line2d &rclLine)
const;
123 bool Intersect(
const BoundBox2d &rclBB)
const;
124 bool Intersect(
const Polygon2d &rclPoly)
const;
142 inline double Length (
void)
const;
147 inline bool operator== (
const Line2d& rclLine)
const;
150 inline bool Contains (
const Vector2d &rclV)
const;
152 bool Intersect (
const Vector2d &rclV,
double eps)
const;
153 bool IntersectAndContain (
const Line2d& rclLine,
Vector2d &rclV)
const;
154 Vector2d FromPos (
double fDistance)
const;
172 inline size_t GetCtVectors (
void)
const;
173 inline bool Add (
const Vector2d &rclVct);
174 inline Vector2d& operator[] (
size_t ulNdx)
const;
175 inline Vector2d& At (
size_t ulNdx)
const;
176 inline bool Delete (
size_t ulNdx);
177 inline void DeleteAll (
void);
181 bool Contains (
const Vector2d &rclV)
const;
183 bool Intersect (
const Polygon2d &rclPolygon)
const;
184 bool Intersect (
const Vector2d &rclV,
double eps)
const;
187 std::vector<Vector2d> _aclVct;
221 return (
x == v.
x) && (
y == v.
y);
272 return x*v.
x +
y*v.
y;
294 return x*
x +
y*
y <= tolerance*tolerance;
299 return sqrt(
x*
x +
y*
y);
335 x =
x*cos(angle) -
y*sin(angle);
336 y =
x*sin(angle) +
y*cos(angle);
359 return Vector2d(r*cos(fi), r*sin(fi));
364 double dx = (
x - v.
x);
365 double dy = (
y - v.
y);
367 return sqrt(dx*dx + dy*dy);
384 _aclVct = rclP._aclVct;
395 return _aclVct.size ();
400 _aclVct.push_back (rclVct);
406 if ( ulNdx < _aclVct.size() )
408 std::vector<Vector2d>::iterator it = _aclVct.begin() + ulNdx;
409 _aclVct.erase ( it );
427 : clV1 (rclLine.clV1),
433 : clV1 (rclV1), clV2 (rclV2)
475 MinX = std::min<double>( fX1, fX2 );
476 MaxX = std::max<double>( fX1, fX2 );
477 MinY = std::min<double>( fY1, fY2 );
478 MaxY = std::max<double>( fY1, fY2 );
527 return v.
x >=
MinX - tolerance && v.
x <=
MaxX + tolerance
528 && v.
y >=
MinY - tolerance && v.
y <=
MaxY + tolerance;
552 #endif // BASE_TOOLS2D_H bool Add(const Vector2d &rclVct)
Definition: Tools2D.h:398
bool Delete(size_t ulNdx)
Definition: Tools2D.h:404
virtual ~Polygon2d()
Definition: Tools2D.h:167
Polygon2d(void)
Definition: Tools2D.h:165
BoundBox2d & operator=(const BoundBox2d &rclBB)
Definition: Tools2D.h:492
DualNumber operator-(DualNumber a, DualNumber b)
Definition: DualNumber.h:61
Vector2d & operator=(const Vector2d &v)
Definition: Tools2D.h:212
Vector2d & Normalize(void)
Definition: Tools2D.h:340
Vector2d & Negate(void)
Definition: Tools2D.h:319
static Vector2d FromPolar(double r, double fi)
Definition: Tools2D.h:357
Vector3f & operator *=(Vector3f &rclVect, const Matrix4D &rclMtrx)
Definition: Matrix.h:351
Vector2d & At(size_t ulNdx) const
Definition: Tools2D.h:421
double Distance(const Vector2d &v) const
Definition: Tools2D.h:362
Vector2d & operator-=(const Vector2d &v)
Definition: Tools2D.h:251
void SetVoid(void)
Definition: Tools2D.h:536
double Length(void) const
Definition: Tools2D.h:297
Vector2d operator *(double c) const
Definition: Tools2D.h:258
Vector2d & operator[](size_t ulNdx) const
Definition: Tools2D.h:416
Vector2d Perpendicular(bool clockwise=false) const
Definition: Tools2D.h:352
Vector2d GetCenter(void) const
Definition: Tools2D.h:531
BoundBox2d(void)
Definition: Tools2D.h:459
double Width(void) const
Definition: Tools2D.h:509
double MaxY
Definition: Tools2D.h:100
BoundBox2d CalcBoundBox(void) const
Vector2d & operator *=(double c)
Definition: Tools2D.h:263
double x
Definition: Tools2D.h:48
bool operator==(const Vector2d &v) const
Definition: Tools2D.h:219
DualNumber operator+(DualNumber a, DualNumber b)
Definition: DualNumber.h:51
Vector2d & Scale(double factor)
Definition: Tools2D.h:326
double MinX
Definition: Tools2D.h:100
Polygon2d & operator=(const Polygon2d &rclP)
Definition: Tools2D.h:382
_Precision Distance(const Vector3< _Precision > &v1, const Vector3< _Precision > &v2)
Returns the distance between two points.
Definition: Vector3D.h:220
Definition: Tools2D.h:162
Vector2d clV1
Definition: Tools2D.h:135
Vector2d & operator/=(double c)
Definition: Tools2D.h:285
Definition: AbstractConstraint.h:6
bool IsEqual(const BoundBox2d &, double tolerance) const
Definition: Tools2D.h:486
Definition: Tools2D.h:132
double Length(void) const
Definition: Tools2D.h:437
bool Contains(const Vector2d &rclV) const
Definition: Tools2D.h:454
Vector2d clV2
Definition: Tools2D.h:135
Line2d & operator=(const Line2d &rclLine)
Definition: Tools2D.h:442
Vector2d operator/(double c) const
Definition: Tools2D.h:280
Vector2d(void)
Definition: Tools2D.h:192
Vector2d & Set(double x, double y)
Definition: Tools2D.h:312
void DeleteAll(void)
Definition: Tools2D.h:388
bool IsValid(void)
Definition: Tools2D.h:481
bool IsNull(double tolerance=0.0) const
Definition: Tools2D.h:292
Vector2d & Rotate(double angle)
Definition: Tools2D.h:333
bool IsEqual(const Vector2d &v, double tolerance=0.0) const
Definition: Tools2D.h:370
Definition: AbstractXMLReader.h:5
double MaxX
Definition: Tools2D.h:100
bool operator==(const Line2d &rclLine) const
Definition: Tools2D.h:449
double y
Definition: Tools2D.h:48
double Height(void) const
Definition: Tools2D.h:514
Vector2d operator-(void) const
Definition: Tools2D.h:241
Vector2d & operator+=(const Vector2d &v)
Definition: Tools2D.h:234
DualNumber operator *(DualNumber a, DualNumber b)
Definition: DualNumber.h:71
double MinY
Definition: Tools2D.h:100
Line2d(void)
Definition: Tools2D.h:137
double Angle(void) const
Definition: Tools2D.h:302
double Sqr(void) const
Definition: Tools2D.h:307
Vector2d operator+(void) const
Definition: Tools2D.h:224
bool Contains(const Vector2d &v) const
Definition: Tools2D.h:519
void Add(const Vector2d &v)
Definition: Tools2D.h:542
bool operator==(const BoundBox2d &rclBB) const
Definition: Tools2D.h:501
DualNumber operator/(DualNumber a, DualNumber b)
Definition: DualNumber.h:81
#define DOUBLE_MAX
Definition: Vector3D.h:48
size_t GetCtVectors(void) const
Definition: Tools2D.h:393