CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GeVector2d.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24
25
26
27#ifndef OD_GEVEC2D_H
28#define OD_GEVEC2D_H
30#include "Ge/GeGbl.h"
31
32#include "TD_PackPush.h"
33
34class OdGeMatrix2d;
35class OdGePoint2d;
36
51{
52public:
53
60 OdGeVector2d() : x(0.0), y(0.0) {}
61
72 double xx,
73 double yy) : x(xx), y(yy) {}
74
75 GE_STATIC_EXPORT static const OdGeVector2d kIdentity; // Additive identity vector.
76 GE_STATIC_EXPORT static const OdGeVector2d kXAxis; // X-Axis vector.
77 GE_STATIC_EXPORT static const OdGeVector2d kYAxis; // Y-Axis vector.
78
80 const OdGeMatrix2d& xfm,
81 const OdGeVector2d& vect);
82
91 const OdGeMatrix2d& matrix,
92 const OdGeVector2d& vect)
93 {
94 *this = matrix * vect;
95 return *this;
96 }
97
106 const OdGeVector2d& vect,
107 double scale)
108 {
109 x = scale * vect.x;
110 y = scale * vect.y;
111 return *this;
112 }
113
121 const OdGeMatrix2d& xfm) { return *this = xfm * *this;}
122
134 double angle);
135
143 const OdGeVector2d& line);
144
154 double scale) const
155 {
156 return OdGeVector2d(x*scale, y*scale);
157 }
158 friend inline OdGeVector2d operator*(
159 double scale, const OdGeVector2d& vector
160 ) {
161 return OdGeVector2d(vector.x * scale, vector.y * scale);
162 }
163
173 double scale)
174 {
175 x *= scale;
176 y *= scale;
177 return *this;
178 }
179
189 double scale) const
190 {
191 return OdGeVector2d(x / scale, y / scale);
192 }
193
203 {
204 x /= scale;
205 y /= scale;
206 return *this;
207 }
208
218 const OdGeVector2d& vect) const
219 {
220 return OdGeVector2d(x + vect.x, y + vect.y);
221 }
222
232 const OdGeVector2d& vect)
233 {
234 x += vect.x;
235 y += vect.y;
236 return *this;
237 }
238
248 const OdGeVector2d& vect) const
249 {
250 return OdGeVector2d(x - vect.x, y - vect.y);
251 }
252
262 const OdGeVector2d& vect)
263 {
264 x -= vect.x;
265 y -= vect.y;
266 return *this;
267 }
268
272 const OdGePoint2d& asPoint() const;
273
277 OdGePoint2d& asPoint();
278
286 const OdGeVector2d& vector1,
287 const OdGeVector2d& vector2)
288 {
289 x = vector1.x + vector2.x;
290 y = vector1.y + vector2.y;
291 return *this;
292 }
293
301 return OdGeVector2d(-x, -y);
302 }
303
308 {
309 x = -x;
310 y = -y;
311 return *this;
312 }
313
318 {
319 return OdGeVector2d(-y, x);
320 }
321
328 double angle () const;
329
342 double angleTo (
343 const OdGeVector2d& vect) const;
344
353 double angleToCCW (
354 const OdGeVector2d& vect) const
355 {
356 return OD_ATAN2(crossProduct(vect), dotProduct(vect));
357 }
358
368 const OdGeTol& tol = OdGeContext::gTol) const;
369
380 const OdGeTol& tol = OdGeContext::gTol);
381
399 const OdGeTol& tol,
400 OdGeError& status);
401
411 double normalizeGetLength (double tol = 1.e-300);
412
416 double length () const;
417
421 double lengthSqrd () const
422 {
423 return x*x + y*y;
424 }
425
432 const OdGeTol& tol = OdGeContext::gTol) const;
433
440 const OdGeTol& tol = OdGeContext::gTol) const;
441
449 const OdGeVector2d& vect,
450 const OdGeTol& tol = OdGeContext::gTol) const;
451
470 const OdGeVector2d& vect,
471 const OdGeTol& tol,
472 OdGeError& status) const;
473
481 const OdGeVector2d& vect,
482 const OdGeTol& tol=OdGeContext::gTol) const;
483
502 const OdGeVector2d& vect,
503 const OdGeTol& tol,
504 OdGeError& status) const;
505
513 const OdGeVector2d& vect,
514 const OdGeTol& tol = OdGeContext::gTol) const;
515
534 const OdGeVector2d& vect,
535 const OdGeTol& tol,
536 OdGeError& status) const;
537
543 double dotProduct (
544 const OdGeVector2d& vect) const
545 {
546 return x * vect.x + y * vect.y;
547 }
548
556 const OdGeVector2d& vect) const
557 {
558 return x * vect.y - y * vect.x;
559 }
560
570 const OdGeVector2d& vect) const;
571
581 const OdGeVector2d& vect) const;
582
591 const OdGeVector2d& vect,
592 const OdGeTol& tol = OdGeContext::gTol) const;
593
603 double operator[] (
604 unsigned int i) const
605 {
606 return *(&x + i);
607 }
608
618 double& operator[] (
619 unsigned int i)
620 {
621 return *(&x + i);
622 }
623
630 unsigned int largestElement() const;
631
640 double xx,
641 double yy)
642 {
643 x = xx;
644 y = yy;
645 return *this;
646 }
647
651 operator OdGeMatrix2d () const;
652
653 double x; // X-coordinate.
654 double y; // Y-coordinate.
655};
656
657
658#include "TD_PackPop.h"
659
660
661#include "GePoint2d.h"
662//DOM-IGNORE-BEGIN
664{
665 ODA_ASSUME(sizeof(OdGePoint2d) == 2 * sizeof(double));
666 ODA_ASSUME(sizeof(OdGeVector2d) == 2 * sizeof(double));
667 return *reinterpret_cast<const OdGePoint2d*>(this);
668}
669
671{
672 ODA_ASSUME(sizeof(OdGePoint2d) == 2 * sizeof(double));
673 ODA_ASSUME(sizeof(OdGeVector2d) == 2 * sizeof(double));
674 return *reinterpret_cast<OdGePoint2d*>(this);
675}
676//DOM-IGNORE-END
677#endif
678
#define OD_ATAN2(y, x)
Definition: DebugStuff.h:281
#define ODA_ASSUME(expr)
Definition: DebugStuff.h:180
tol
Definition: DimVarDefs.h:2287
scale
Definition: DimVarDefs.h:1684
#define GE_TOOLKIT_EXPORT
Definition: GeExport.h:49
#define GE_STATIC_EXPORT
Definition: GeExport.h:52
bool operator!=(T left, const OdGiVariant::EnumType right)
Definition: GiVariant.h:403
bool operator==(T left, const OdGiVariant::EnumType right)
Definition: GiVariant.h:397
Definition: GeTol.h:49
OdGeVector2d & setToProduct(const OdGeMatrix2d &matrix, const OdGeVector2d &vect)
Definition: GeVector2d.h:90
OdGeVector2d operator-() const
Definition: GeVector2d.h:300
double crossProduct(const OdGeVector2d &vect) const
Definition: GeVector2d.h:555
bool isPerpendicularTo(const OdGeVector2d &vect, const OdGeTol &tol, OdGeError &status) const
static GE_STATIC_EXPORT const OdGeVector2d kYAxis
Definition: GeVector2d.h:77
OdGeVector2d & operator+=(const OdGeVector2d &vect)
Definition: GeVector2d.h:231
double angle() const
bool isCodirectionalTo(const OdGeVector2d &vect, const OdGeTol &tol=OdGeContext::gTol) const
OdGeVector2d(double xx, double yy)
Definition: GeVector2d.h:71
OdGeVector2d & normalize(const OdGeTol &tol=OdGeContext::gTol)
OdGeVector2d operator+(const OdGeVector2d &vect) const
Definition: GeVector2d.h:217
bool isZeroLength(const OdGeTol &tol=OdGeContext::gTol) const
bool isParallelTo(const OdGeVector2d &vect, const OdGeTol &tol=OdGeContext::gTol) const
OdGeVector2d & rotateBy(double angle)
double dotProduct(const OdGeVector2d &vect) const
Definition: GeVector2d.h:543
friend OdGeVector2d operator*(double scale, const OdGeVector2d &vector)
Definition: GeVector2d.h:158
double lengthSqrd() const
Definition: GeVector2d.h:421
OdGeVector2d & operator-=(const OdGeVector2d &vect)
Definition: GeVector2d.h:261
OdGeVector2d perpVector() const
Definition: GeVector2d.h:317
OdGeVector2d & normalize(const OdGeTol &tol, OdGeError &status)
OdGeVector2d normal(const OdGeTol &tol=OdGeContext::gTol) const
OdGeVector2d operator/(double scale) const
Definition: GeVector2d.h:188
bool isEqualTo(const OdGeVector2d &vect, const OdGeTol &tol=OdGeContext::gTol) const
OdGeVector2d operator*(double scale) const
Definition: GeVector2d.h:153
unsigned int largestElement() const
OdGeVector2d & setToSum(const OdGeVector2d &vector1, const OdGeVector2d &vector2)
Definition: GeVector2d.h:285
static GE_STATIC_EXPORT const OdGeVector2d kIdentity
Definition: GeVector2d.h:75
OdGeVector2d & transformBy(const OdGeMatrix2d &xfm)
Definition: GeVector2d.h:120
OdGeVector2d & operator*=(double scale)
Definition: GeVector2d.h:172
double angleToCCW(const OdGeVector2d &vect) const
Definition: GeVector2d.h:353
bool isPerpendicularTo(const OdGeVector2d &vect, const OdGeTol &tol=OdGeContext::gTol) const
OdGeVector2d & negate()
Definition: GeVector2d.h:307
bool isUnitLength(const OdGeTol &tol=OdGeContext::gTol) const
bool isCodirectionalTo(const OdGeVector2d &vect, const OdGeTol &tol, OdGeError &status) const
OdGeVector2d & setToProduct(const OdGeVector2d &vect, double scale)
Definition: GeVector2d.h:105
double length() const
OdGeVector2d & set(double xx, double yy)
Definition: GeVector2d.h:639
friend GE_TOOLKIT_EXPORT OdGeVector2d operator*(const OdGeMatrix2d &xfm, const OdGeVector2d &vect)
bool isParallelTo(const OdGeVector2d &vect, const OdGeTol &tol, OdGeError &status) const
static GE_STATIC_EXPORT const OdGeVector2d kXAxis
Definition: GeVector2d.h:76
OdGeVector2d & mirror(const OdGeVector2d &line)
double angleTo(const OdGeVector2d &vect) const
OdGeVector2d operator-(const OdGeVector2d &vect) const
Definition: GeVector2d.h:247
const OdGePoint2d & asPoint() const
Definition: GeVector2d.h:663
OdGeVector2d & operator/=(double scale)
Definition: GeVector2d.h:202
double normalizeGetLength(double tol=1.e-300)
GLfloat x
Definition: gles2_ext.h:314
GLfloat GLfloat y
Definition: gles2_ext.h:316
static GE_STATIC_EXPORT OdGeTol gTol
Definition: GeGbl.h:65
ErrorCondition
Definition: Ge.h:413