CFx SDK Documentation  2020SP3
GeVector3d.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 
26 
27 #ifndef OD_GEVEC3D_H
28 #define OD_GEVEC3D_H
31 #include "Ge/GeGbl.h"
32 #include "Ge/GeVector2d.h" // for convert2d
33 
34 class OdGeMatrix3d;
35 class OdGePlane;
36 class OdGePlanarEnt;
37 
38 #include "TD_PackPush.h"
39 
54 {
55 public:
78  OdGeVector3d () : x(0.0), y(0.0), z(0.0) {}
79 
81  double xx,
82  double yy,
83  double zz) : x(xx), y(yy), z(zz) {}
85  const OdGePlanarEnt& plane,
86  const OdGeVector2d& vector2d);
87 
88  GE_STATIC_EXPORT static const OdGeVector3d kIdentity; // Additive identity vector.
89  GE_STATIC_EXPORT static const OdGeVector3d kXAxis; // X-Axis vector.
90  GE_STATIC_EXPORT static const OdGeVector3d kYAxis; // Y-Axis vector.
91  GE_STATIC_EXPORT static const OdGeVector3d kZAxis; // Z-Axis vector.
92 
101  const OdGeMatrix3d& matrix,
102  const OdGeVector3d& vect);
103 
112  const OdGeVector3d& vect,
113  double scale)
114  {
115  x = scale * vect.x;
116  y = scale * vect.y;
117  z = scale * vect.z;
118  return *this;
119  }
120 
121 
128  const OdGeMatrix3d& xfm);
129 
139  double angle,
140  const OdGeVector3d& axis);
141 
150  const OdGeVector3d& normalToPlane);
151 
162  const OdGePlanarEnt& plane) const;
163 
173  OdGeVector2d convert2d () const { return OdGeVector2d(x, y); }
174 
176  double scale) const
177  { return OdGeVector3d (x * scale, y * scale, z * scale); }
178 
179  OdGeVector3d& operator *= (
180  double scale)
181  {
182  x *= scale;
183  y *= scale;
184  z *= scale;
185  return *this;
186  }
187 
188  OdGeVector3d operator / (
189  double scale) const
190  {
191  return OdGeVector3d (x/scale, y/scale, z/scale);
192  }
193 
194  OdGeVector3d& operator /= (
195  double scale)
196  {
197  x /= scale;
198  y /= scale;
199  z /= scale;
200  return *this;
201  }
202 
203  OdGeVector3d operator + (
204  const OdGeVector3d& vect) const
205  { return OdGeVector3d (x + vect.x, y + vect.y, z + vect.z);}
206  OdGeVector3d operator += (
207  const OdGeVector3d& vect)
208  { return OdGeVector3d (x += vect.x, y += vect.y, z += vect.z);}
209 
210  OdGeVector3d operator - (
211  const OdGeVector3d& vect) const
212  { return OdGeVector3d (x - vect.x, y - vect.y, z - vect.z);}
213  OdGeVector3d operator -= (
214  const OdGeVector3d& vect)
215  { return OdGeVector3d (x -= vect.x, y -= vect.y, z -= vect.z);}
216 
217 
225  const OdGeVector3d& vector1,
226  const OdGeVector3d& vector2)
227  {
228  x = vector1.x + vector2.x;
229  y = vector1.y + vector2.y;
230  z = vector1.z + vector2.z;
231  return *this;
232  }
233 
234  OdGeVector3d operator - () const { return OdGeVector3d (-x, -y, -z); }
235 
240  {
241  x = -x;
242  y = -y;
243  z = -z;
244  return *this;
245  }
246 
247 
255 
256 
267  double angleTo (
268  const OdGeVector3d& vect) const;
269 
281  double angleTo (
282  const OdGeVector3d& vect,
283  const OdGeVector3d& refVector) const;
284 
298  double angleOnPlane(
299  const OdGePlanarEnt& plane) const;
300 
310  const OdGeTol& tol = OdGeContext::gTol) const;
311 
322  const OdGeTol& tol = OdGeContext::gTol);
323 
341  const OdGeTol& tol,
342  OdGe::ErrorCondition& status);
343 
351  double normalizeGetLength(double tol = 1.e-300);
352 
356  double length () const;
357 
361  void setLength(double length);
362 
366  double lengthSqrd () const { return x*x + y*y + z*z; }
367 
368 
375  const OdGeTol& tol = OdGeContext::gTol) const;
376 
383  const OdGeTol& tol = OdGeContext::gTol) const;
384 
392  const OdGeVector3d& vect,
393  const OdGeTol& tol = OdGeContext::gTol) const;
394 
413  const OdGeVector3d& vect,
414  const OdGeTol& tol,
415  OdGeError& status) const;
416 
424  const OdGeVector3d& vect,
425  const OdGeTol& tol = OdGeContext::gTol) const;
426 
445  const OdGeVector3d& vect,
446  const OdGeTol& tol,
447  OdGeError& status) const;
448 
449 
457  const OdGeVector3d& vect,
458  const OdGeTol& tol = OdGeContext::gTol) const;
459 
478  const OdGeVector3d& vect,
479  const OdGeTol& tol,
480  OdGeError& status) const;
481 
487  double dotProduct (
488  const OdGeVector3d& vect) const
489  { return x * vect.x + y * vect.y + z * vect.z; }
490 
491 
498  const OdGeVector3d& vect) const;
499 
500  // OdGeMatrix3d rotateTo (const OdGeVector3d& vector, const OdGeVector3d& axis
501  // = OdGeVector3d::kIdentity) const;
502 
503  // OdGeVector3d project (const OdGeVector3d& planeNormal,
504  // const OdGeVector3d& projectDirection) const;
505  // OdGeVector3d project (const OdGeVector3d& planeNormal,
506  // const OdGeVector3d& projectDirection,
507  // const OdGeTol& tol, OdGeError& flag) const;
508 
509  OdGeVector3d orthoProject (const OdGeVector3d& planeNormal) const;
510  OdGeVector3d orthoProject (const OdGeVector3d& planeNormal,
511  const OdGeTol& tol, OdGeError& flag) const;
512 
514  const OdGeVector3d& vect) const;
516  const OdGeVector3d& vect) const;
517 
525  bool isEqualTo (
526  const OdGeVector3d& vect,
527  const OdGeTol& tol = OdGeContext::gTol) const;
528 
538  double operator [] (
539  unsigned int i) const {return * (&x + i); }
540  double& operator [] (
541  unsigned int i) {return * (&x + i); }
545  unsigned int largestElement() const;
546 
556  double xx,
557  double yy,
558  double zz)
559  {
560  x = xx;
561  y = yy;
562  z = zz;
563  return *this;
564  }
565 
587  const OdGePlanarEnt& plane,
588  const OdGeVector2d& vect);
589 
593  operator OdGeMatrix3d () const;
594 
595 /*
596  static OdGeVector3d givePerp (
597  const OdGeVector2d& vector1,
598  const OdGeVector2d& vector2);
599 */
600 
601  double x; // X-coordinate.
602  double y; // Y-coordinate.
603  double z; // Z-coordinate.
604 };
605 
606 
617  const OdGeMatrix3d& matrix,
618  const OdGeVector3d& vect);
620  double scale,
621  const OdGeVector3d& vect);
622 
623 #include "TD_PackPop.h"
624 
625 #endif
626 
OdGeVector3d::normalize
OdGeVector3d & normalize(const OdGeTol &tol=OdGeContext::gTol)
OdGeVector3d::largestElement
unsigned int largestElement() const
OdGePlane
Definition: GePlane.h:45
OdGeVector3d::isPerpendicularTo
bool isPerpendicularTo(const OdGeVector3d &vect, const OdGeTol &tol=OdGeContext::gTol) const
OdGeVector3d
Definition: GeVector3d.h:54
GeVector2d.h
scale
scale
Definition: DimVarDefs.h:1684
OdGeVector3d::normalize
OdGeVector3d & normalize(const OdGeTol &tol, OdGe::ErrorCondition &status)
OdGeVector3d::normalizeGetLength
double normalizeGetLength(double tol=1.e-300)
tol
tol
Definition: DimVarDefs.h:2287
OdGeVector3d::x
double x
Definition: GeVector3d.h:601
OdGeVector3d::z
double z
Definition: GeVector3d.h:603
OdGeVector3d::set
OdGeVector3d & set(double xx, double yy, double zz)
Definition: GeVector3d.h:555
OdGeVector3d::kXAxis
static GE_STATIC_EXPORT const OdGeVector3d kXAxis
Definition: GeVector3d.h:89
OdGeVector3d::setToProduct
OdGeVector3d & setToProduct(const OdGeVector3d &vect, double scale)
Definition: GeVector3d.h:111
OdGeVector3d::isEqualTo
bool isEqualTo(const OdGeVector3d &vect, const OdGeTol &tol=OdGeContext::gTol) const
TD_PackPop.h
OdGeVector3d::isCodirectionalTo
bool isCodirectionalTo(const OdGeVector3d &vect, const OdGeTol &tol, OdGeError &status) const
OdGeVector3d::orthoProject
OdGeVector3d orthoProject(const OdGeVector3d &planeNormal, const OdGeTol &tol, OdGeError &flag) const
x
GLfloat x
Definition: gles2_ext.h:314
OdGeVector3d::lengthSqrd
double lengthSqrd() const
Definition: GeVector3d.h:366
OdGeVector3d::normal
OdGeVector3d normal(const OdGeTol &tol=OdGeContext::gTol) const
OdGeVector3d::angleTo
double angleTo(const OdGeVector3d &vect) const
OdGeMatrix3d
Definition: GeMatrix3d.h:73
OdGeVector3d::convert2d
OdGeVector2d convert2d(const OdGePlanarEnt &plane) const
operator*
GE_TOOLKIT_EXPORT OdGeVector3d operator*(const OdGeMatrix3d &matrix, const OdGeVector3d &vect)
OdGeVector3d::kIdentity
static GE_STATIC_EXPORT const OdGeVector3d kIdentity
Definition: GeVector3d.h:88
OdGePlanarEnt
Definition: GePlanarEnt.h:62
OdGeVector3d::length
double length() const
OdGeVector3d::set
OdGeVector3d & set(const OdGePlanarEnt &plane, const OdGeVector2d &vect)
OdGeVector3d::OdGeVector3d
OdGeVector3d()
Definition: GeVector3d.h:78
OdGeVector3d::kZAxis
static GE_STATIC_EXPORT const OdGeVector3d kZAxis
Definition: GeVector3d.h:91
OdDAI::operator!=
bool DAI_EXPORT operator!=(const OdDAI::OdSelect &left, const OdDAI::OdSelect &right)
OdGeVector3d::perpVector
OdGeVector3d perpVector() const
OdGeVector3d::OdGeVector3d
OdGeVector3d(double xx, double yy, double zz)
Definition: GeVector3d.h:80
OdGeVector3d::setToSum
OdGeVector3d & setToSum(const OdGeVector3d &vector1, const OdGeVector3d &vector2)
Definition: GeVector3d.h:224
OdGeVector3d::isParallelTo
bool isParallelTo(const OdGeVector3d &vect, const OdGeTol &tol=OdGeContext::gTol) const
OdGeVector3d::crossProduct
OdGeVector3d crossProduct(const OdGeVector3d &vect) const
y
GLfloat GLfloat y
Definition: gles2_ext.h:316
OdGeVector3d::transformBy
OdGeVector3d & transformBy(const OdGeMatrix3d &xfm)
OdGeVector3d::orthoProject
OdGeVector3d orthoProject(const OdGeVector3d &planeNormal) const
length
GLuint GLsizei GLsizei * length
Definition: gles2_ext.h:274
OdGeVector2d
Definition: GeVector2d.h:51
OdGeVector3d::isZeroLength
bool isZeroLength(const OdGeTol &tol=OdGeContext::gTol) const
TD_PackPush.h
OdGeVector3d::isUnitLength
bool isUnitLength(const OdGeTol &tol=OdGeContext::gTol) const
OdGeVector3d::OdGeVector3d
OdGeVector3d(const OdGePlanarEnt &plane, const OdGeVector2d &vector2d)
OdGeVector3d::isPerpendicularTo
bool isPerpendicularTo(const OdGeVector3d &vect, const OdGeTol &tol, OdGeError &status) const
OdGeVector3d::isParallelTo
bool isParallelTo(const OdGeVector3d &vect, const OdGeTol &tol, OdGeError &status) const
OdGeVector3d::setToProduct
OdGeVector3d & setToProduct(const OdGeMatrix3d &matrix, const OdGeVector3d &vect)
OdGeContext::gTol
static GE_STATIC_EXPORT OdGeTol gTol
Definition: GeGbl.h:60
GE_TOOLKIT_EXPORT
#define GE_TOOLKIT_EXPORT
Definition: GeExport.h:49
OdGeVector3d::angleTo
double angleTo(const OdGeVector3d &vect, const OdGeVector3d &refVector) const
OdGe::ErrorCondition
ErrorCondition
Definition: Ge.h:228
OdGeVector3d::kYAxis
static GE_STATIC_EXPORT const OdGeVector3d kYAxis
Definition: GeVector3d.h:90
OdDAI::operator==
bool DAI_EXPORT operator==(const OdFileDescriptionAuto &left, const OdFileDescriptionAuto &right)
GE_STATIC_EXPORT
#define GE_STATIC_EXPORT
Definition: GeExport.h:53
OdGeVector3d::rotateBy
OdGeVector3d & rotateBy(double angle, const OdGeVector3d &axis)
OdGeTol
Definition: GeTol.h:49
OdGeVector3d::y
double y
Definition: GeVector3d.h:602
OdGeVector3d::convert2d
OdGeVector2d convert2d() const
Definition: GeVector3d.h:173
OdGeVector3d::angleOnPlane
double angleOnPlane(const OdGePlanarEnt &plane) const
z
GLfloat GLfloat GLfloat z
Definition: gles2_ext.h:318
OdGeVector3d::mirror
OdGeVector3d & mirror(const OdGeVector3d &normalToPlane)
OdGeVector3d::negate
OdGeVector3d & negate()
Definition: GeVector3d.h:239
OdGeVector3d::isCodirectionalTo
bool isCodirectionalTo(const OdGeVector3d &vect, const OdGeTol &tol=OdGeContext::gTol) const
OdGeVector3d::dotProduct
double dotProduct(const OdGeVector3d &vect) const
Definition: GeVector3d.h:487
OdGeVector3d::setLength
void setLength(double length)