CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GePoint2d.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#ifndef OD_GEPNT2D_H
26#define OD_GEPNT2D_H
28#include "Ge/GeGbl.h"
29
30#ifdef OD_HAVE_MATH_FILE
31#include <math.h>
32#endif
33
34#ifdef OD_HAVE_COMPLEX_FILE
35#if __cplusplus >= 201103L
36#include <sstream>
37#else
38#include <complex>
39#endif
40#endif
41
42class OdGeMatrix2d;
43class OdGeVector2d;
44class OdGeLinearEnt2d;
45class OdGeLine2d;
46
47#include "TD_PackPush.h"
48
63{
64public:
65
73 : x (0.0), y (0.0)
74 {
75 }
76
87 double xx,
88 double yy)
89 : x (xx), y (yy)
90 {
91 }
92
93 GE_STATIC_EXPORT static const OdGePoint2d kOrigin; // Origin (0,0).
94
102 const OdGeMatrix2d& matrix,
103 const OdGePoint2d& point);
104
111 friend inline OdGePoint2d operator *(
112 double scale,
113 const OdGePoint2d& point)
114 {
115 return OdGePoint2d(point.x * scale, point.y * scale);
116 }
117
126 const OdGeMatrix2d& matrix,
127 const OdGePoint2d& point);
128
136 const OdGeMatrix2d& xfm);
137
145 double angle,
146 const OdGePoint2d& basePoint = kOrigin);
147
154 const OdGeLine2d& line);
155
163 double scaleFactor,
164 const OdGePoint2d& basePoint = kOrigin);
165
175 double scale) const
176 {
177 return OdGePoint2d (x*scale, y*scale);
178 }
179
188 OdGePoint2d& operator *=(
189 double scale)
190 {
191 x *= scale;
192 y *= scale;
193 return *this;
194 }
195
204 OdGePoint2d operator /(
205 double scale) const
206 {
207 return OdGePoint2d (x/scale, y/scale);
208 }
209
218 OdGePoint2d& operator /=(
219 double scale)
220 {
221 x /= scale;
222 y /= scale;
223 return *this;
224 }
225
234 OdGePoint2d operator +(
235 const OdGeVector2d& vect) const;
236
245 OdGePoint2d& operator +=(
246 const OdGeVector2d& vect);
247
256 OdGePoint2d operator -(
257 const OdGeVector2d& vect) const;
258
267 OdGePoint2d& operator -=(
268 const OdGeVector2d& vect);
269
277 const OdGePoint2d& point,
278 const OdGeVector2d& vect);
279
288 OdGeVector2d operator -(
289 const OdGePoint2d& point) const;
290
294 const OdGeVector2d& asVector() const;
295
299 OdGeVector2d& asVector();
300
307 const OdGePoint2d& point) const
308 {
309 return sqrt((x-point.x) * (x-point.x) + (y-point.y) * (y-point.y));
310 }
311
318 const OdGePoint2d& point) const
319 {
320 double dx = x - point.x;
321 double dy = y - point.y;
322 double r = dx*dx + dy*dy;
323 return r;
324 }
325
333 const OdGePoint2d& point) const
334 {
335 return isEqualTo (point);
336 }
337
345 const OdGePoint2d& point) const
346 {
347 return !isEqualTo (point);
348 }
349
358 const OdGePoint2d& point,
359 const OdGeTol& tol = OdGeContext::gTol) const;
360
371 double& operator [](
372 unsigned int i)
373 {
374 return * (&x+i);
375 }
376
387 double operator [](
388 unsigned int i) const
389 {
390 return * (&x+i);
391 }
392
401 double xx,
402 double yy)
403 {
404 x = xx;
405 y = yy;
406 return *this;
407 }
408
409 double x; // X-coordinate
410 double y; // Y-coordinate
411};
412
413#include "TD_PackPop.h"
414
415
416#include "Ge/GeVector2d.h"
417//DOM-IGNORE-BEGIN
419 const OdGeVector2d& vect) const
420{
421 return OdGePoint2d(x + vect.x, y + vect.y);
422}
423
425 const OdGeVector2d& vect)
426{
427 x += vect.x;
428 y += vect.y;
429 return *this;
430}
431
433 const OdGeVector2d& vect) const
434{
435 return OdGePoint2d(x - vect.x, y - vect.y);
436}
437
439 const OdGeVector2d& vect)
440{
441 x -= vect.x;
442 y -= vect.y;
443 return *this;
444}
445
447 const OdGePoint2d& point) const
448{
449 return OdGeVector2d(x - point.x, y - point.y);
450}
451
453{
454 ODA_ASSUME(sizeof(OdGePoint2d) == 2 * sizeof(double));
455 ODA_ASSUME(sizeof(OdGeVector2d) == 2 * sizeof(double));
456 return *reinterpret_cast<const OdGeVector2d*>(this);
457}
458
460{
461 ODA_ASSUME(sizeof(OdGePoint2d) == 2 * sizeof(double));
462 ODA_ASSUME(sizeof(OdGeVector2d) == 2 * sizeof(double));
463 return *reinterpret_cast<OdGeVector2d*>(this);
464}
465//DOM-IGNORE-END
466#endif
467
AECBASE_API OdGePoint3d operator*(const AECECS &matrix, const OdGePoint3d &point)
#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
double x
Definition: GePoint2d.h:409
OdGePoint2d & mirror(const OdGeLine2d &line)
OdGePoint2d & set(double xx, double yy)
Definition: GePoint2d.h:400
OdGePoint2d & operator-=(const OdGeVector2d &vect)
Definition: GePoint2d.h:438
double y
Definition: GePoint2d.h:410
OdGePoint2d & transformBy(const OdGeMatrix2d &xfm)
bool isEqualTo(const OdGePoint2d &point, const OdGeTol &tol=OdGeContext::gTol) const
OdGePoint2d & rotateBy(double angle, const OdGePoint2d &basePoint=kOrigin)
static GE_STATIC_EXPORT const OdGePoint2d kOrigin
Definition: GePoint2d.h:93
double distanceTo(const OdGePoint2d &point) const
Definition: GePoint2d.h:306
OdGePoint2d & operator+=(const OdGeVector2d &vect)
Definition: GePoint2d.h:424
double distanceSqrdTo(const OdGePoint2d &point) const
Definition: GePoint2d.h:317
OdGePoint2d operator-(const OdGeVector2d &vect) const
Definition: GePoint2d.h:432
OdGePoint2d(double xx, double yy)
Definition: GePoint2d.h:86
OdGePoint2d & scaleBy(double scaleFactor, const OdGePoint2d &basePoint=kOrigin)
const OdGeVector2d & asVector() const
Definition: GePoint2d.h:452
OdGePoint2d & setToSum(const OdGePoint2d &point, const OdGeVector2d &vect)
OdGePoint2d operator+(const OdGeVector2d &vect) const
Definition: GePoint2d.h:418
OdGePoint2d & setToProduct(const OdGeMatrix2d &matrix, const OdGePoint2d &point)
Definition: GeTol.h:49
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