CFx SDK Documentation  2023 SP0
GePoint2d.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, 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 Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 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/GeVector2d.h"
29 #include "OdArray.h"
30 
31 #ifdef OD_HAVE_MATH_FILE
32 #include <math.h>
33 #endif
34 
35 #ifdef OD_HAVE_COMPLEX_FILE
36 #include <complex>
37 #endif
38 
39 class OdGeMatrix2d;
40 class OdGeVector2d;
41 class OdGeLinearEnt2d;
42 class OdGeLine2d;
43 
44 #include "TD_PackPush.h"
45 
60 {
61 public:
70  : x (0.0), y (0.0)
71  {
72  }
74  double xx,
75  double yy)
76  : x (xx), y (yy)
77  {
78  }
79 
80  GE_STATIC_EXPORT static const OdGePoint2d kOrigin; // Origin (0,0).
81 
91  const OdGeMatrix2d& matrix,
92  const OdGePoint2d& point);
93 
95  double scale,
96  const OdGePoint2d& point);
97 
106  const OdGeMatrix2d& matrix,
107  const OdGePoint2d& point);
108 
116  const OdGeMatrix2d& xfm);
117 
125  double angle,
126  const OdGePoint2d& basePoint = kOrigin);
127 
134  const OdGeLine2d& line);
135 
143  double scaleFactor,
144  const OdGePoint2d& basePoint = kOrigin);
145 
147  double scale) const
148  {
149  return OdGePoint2d (x*scale, y*scale);
150  }
151 
152  OdGePoint2d& operator *=(
153  double scale)
154  {
155  x *= scale;
156  y *= scale;
157  return *this;
158  }
159 
160  OdGePoint2d operator /(
161  double scale) const
162  {
163  return OdGePoint2d (x/scale, y/scale);
164  }
165 
166  OdGePoint2d& operator /=(
167  double scale)
168  {
169  x /= scale;
170  y /= scale;
171  return *this;
172  }
173 
174  OdGePoint2d operator +(
175  const OdGeVector2d& vect) const
176  {
177  return OdGePoint2d (x + vect.x, y + vect.y);
178  }
179 
180  OdGePoint2d& operator +=(
181  const OdGeVector2d& vect)
182  {
183  x += vect.x;
184  y += vect.y;
185  return *this;
186  }
187 
188  OdGePoint2d operator -(
189  const OdGeVector2d& vect) const
190  {
191  return OdGePoint2d (x - vect.x, y - vect.y);
192  }
193 
194  OdGePoint2d& operator -=(
195  const OdGeVector2d& vect)
196  {
197  x -= vect.x;
198  y -= vect.y;
199  return *this;
200  }
201 
209  const OdGePoint2d& point,
210  const OdGeVector2d& vect)
211  {
212  x = point.x + vect.x;
213  y = point.y + vect.y;
214  return *this;
215  }
216 
217  OdGeVector2d operator -(
218  const OdGePoint2d& point) const
219  {
220  return OdGeVector2d (x - point.x, y - point.y);
221  }
222 
226  const OdGeVector2d& asVector() const
227  {
228  return *reinterpret_cast<const OdGeVector2d*>(this);
229  }
230 
236  double distanceTo(
237  const OdGePoint2d& point) const
238  {
239  return sqrt ( (x-point.x)* (x-point.x)+ (y-point.y)* (y-point.y));
240  }
241 
243  const OdGePoint2d& point) const
244  {
245  return isEqualTo (point);
246  }
248  const OdGePoint2d& point) const
249  {
250  return !isEqualTo (point);
251  }
252 
260  bool isEqualTo(
261  const OdGePoint2d& point,
262  const OdGeTol& tol = OdGeContext::gTol) const;
263 
272  double& operator [](
273  unsigned int i)
274  {
275  return * (&x+i);
276  }
277  double operator [](
278  unsigned int i) const
279  {
280  return * (&x+i);
281  }
282 
291  double xx,
292  double yy)
293  {
294  x = xx;
295  y = yy;
296  return *this;
297  }
298 
299  double x; // X-coordinate
300  double y; // Y-coordinate
301 };
302 
303 #include "TD_PackPop.h"
304 
305 #endif
306 
AECBASE_API OdGePoint3d operator*(const AECECS &matrix, const OdGePoint3d &point)
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:53
double x
Definition: GePoint2d.h:299
OdGePoint2d & set(double xx, double yy)
Definition: GePoint2d.h:290
OdGePoint2d & setToProduct(const OdGeMatrix2d &matrix, const OdGePoint2d &point)
OdGePoint2d & rotateBy(double angle, const OdGePoint2d &basePoint=kOrigin)
double y
Definition: GePoint2d.h:300
bool isEqualTo(const OdGePoint2d &point, const OdGeTol &tol=OdGeContext::gTol) const
OdGePoint2d & transformBy(const OdGeMatrix2d &xfm)
static GE_STATIC_EXPORT const OdGePoint2d kOrigin
Definition: GePoint2d.h:80
double distanceTo(const OdGePoint2d &point) const
Definition: GePoint2d.h:236
OdGePoint2d & scaleBy(double scaleFactor, const OdGePoint2d &basePoint=kOrigin)
OdGePoint2d(double xx, double yy)
Definition: GePoint2d.h:73
OdGePoint2d & mirror(const OdGeLine2d &line)
OdGePoint2d & setToSum(const OdGePoint2d &point, const OdGeVector2d &vect)
Definition: GePoint2d.h:208
const OdGeVector2d & asVector() const
Definition: GePoint2d.h:226
Definition: GeTol.h:49
GLfloat x
Definition: gles2_ext.h:314
GLfloat GLfloat y
Definition: gles2_ext.h:316
bool operator==(const BlockRefPath &rA, const BlockRefPath &rB)
DOM.
bool operator!=(const BlockRefPath &rA, const BlockRefPath &rB)
DOM.
static GE_STATIC_EXPORT OdGeTol gTol
Definition: GeGbl.h:60