OpenLexocad  28.0
Dir.h
Go to the documentation of this file.
1 //
3 // Copyright(C) 2013-2016 OpenCascade [www.opencascade.org]
4 //
5 // This library is free software; you can redistribute it and / or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street,
18 // Fifth Floor, Boston, MA 02110 - 1301 USA
19 //
21 
22 
23 #pragma once
24 
25 #include <Geom/XYZ.h>
26 #include <QString>
27 
28 namespace Geom
29 {
30 class Ax1;
31 class Ax2;
32 class Trsf;
33 class Vec;
34 class Dir;
35 
36 
44 class LX_GEOM_EXPORT Dir
45 {
46 public:
48  // //
49  // --------------------- BEGIN API --------------------- //
50  // //
51  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
52  // //
54 
55  // Methods PUBLIC
56  //
58  Dir();
60  Dir(const Geom::Vec& V);
62  Dir(const Geom::XYZ& Coord);
69  Dir(const double Xv, const double Yv, const double Zv);
71  Dir(const Dir& rhs);
72 
73  // named constr.
74  static Dir XDir() { return Dir(1, 0, 0); };
75  static Dir YDir() { return Dir(0, 1, 0); };
76  static Dir ZDir() { return Dir(0, 0, 1); };
77 
94  void setCoord(const int Index, const double Xi);
98  void setCoord(const double Xv, const double Yv, const double Zv);
100  void setX(const double X);
102  void setY(const double Y);
104  void setZ(const double Z);
106  void setXYZ(const Geom::XYZ& Coord);
107 
114  double coord(const int Index) const;
116  void coord(double& Xv, double& Yv, double& Zv) const;
118  double x() const;
120  double y() const;
122  double z() const;
124  const Geom::XYZ& xyz() const;
125 
128  bool isEqual(const Dir& Other, const double AngularTolerance) const;
129 
131  bool isNormal(const Dir& Other, const double AngularTolerance) const;
132 
134  bool isOpposite(const Dir& Other, const double AngularTolerance) const;
135 
139  bool isParallel(const Dir& Other, const double AngularTolerance) const;
140 
141 
145  double angle(const Dir& Other) const;
146 
147 
155  double angleWithRef(const Dir& Other, const Dir& VRef) const;
160  void cross(const Dir& Right);
161  void operator^=(const Dir& Right) { cross(Right); }
162 
168  Dir crossed(const Dir& Right) const;
169  Dir operator^(const Dir& Right) const { return crossed(Right); }
170 
171 
172  void crossCross(const Dir& V1, const Dir& V2);
181  Dir crossCrossed(const Dir& V1, const Dir& V2) const;
183  double dot(const Dir& Other) const;
184  double operator*(const Dir& Other) const { return dot(Other); }
185 
186 
192  double dotCross(const Dir& V1, const Dir& V2) const;
193 
194  void reverse();
199  Dir reversed() const;
200  Dir operator-() const { return reversed(); }
201 
202 
203 
204  void mirror(const Dir& V);
205 
206 
210  Dir mirrored(const Dir& V) const;
211 
212 
213  void mirror(const Geom::Ax1& A1);
214 
215 
219  Dir mirrored(const Geom::Ax1& A1) const;
220 
221 
222  void mirror(const Geom::Ax2& A2);
223 
224 
228  Dir mirrored(const Geom::Ax2& A2) const;
229 
230  void rotate(const Geom::Ax1& A1, const double Ang);
231 
234  Dir rotated(const Geom::Ax1& A1, const double Ang) const;
235 
236 
237  void transform(const Geom::Trsf& T);
238 
243  Dir transformed(const Geom::Trsf& T) const;
244 
246  // //
247  // ---------------------- END API ---------------------- //
248  // //
250 
252  bool operator==(const Geom::Dir& other) const;
253 
254 
255  double& operator[](int i);
256  const double& operator[](int i) const;
257 
258 
259 private:
260  Geom::XYZ _coord;
261 };
262  LX_GEOM_EXPORT QString to_string(const Dir& dir);
263 
264 } // namespace Geom
Geom::Dir::setXYZ
void setXYZ(const Geom::XYZ &Coord)
Assigns the three coordinates of Coord to this unit vector.
Geom::Dir::cross
void cross(const Dir &Right)
Geom::Dir::rotated
Dir rotated(const Geom::Ax1 &A1, const double Ang) const
Geom::Dir::mirror
void mirror(const Dir &V)
Geom::Dir::angleWithRef
double angleWithRef(const Dir &Other, const Dir &VRef) const
Geom::Dir::operator*
double operator*(const Dir &Other) const
Definition: Dir.h:184
Geom::Dir::xyz
const Geom::XYZ & xyz() const
for this unit vector, returns its three coordinates as a number triplea.
Geom::Dir::reverse
void reverse()
Geom::Dir::isOpposite
bool isOpposite(const Dir &Other, const double AngularTolerance) const
Returns True if the angle between this unit vector and the unit vector Other is equal to Pi (opposite...
Geom::Dir::dotCross
double dotCross(const Dir &V1, const Dir &V2) const
Geom::Dir::setY
void setY(const double Y)
Assigns the given value to the Y coordinate of this unit vector.
Geom::Dir::crossed
Dir crossed(const Dir &Right) const
Geom::Dir::mirrored
Dir mirrored(const Geom::Ax1 &A1) const
XYZ.h
Geom::Dir::Dir
Dir()
Creates an indefinite direction.
Geom::Vec
Defines a non-persistent vector in 3D space.
Definition: Vec.h:41
Geom::Dir::transform
void transform(const Geom::Trsf &T)
X
X
Definition: Globals.h:29
Geom::Dir::isEqual
bool isEqual(const Dir &Other, const double AngularTolerance) const
Geom::Dir::mirror
void mirror(const Geom::Ax1 &A1)
Geom::Dir::operator==
bool operator==(const Geom::Dir &other) const
Checks whether two points are equal within linear tolerance (default 1E-07)
Geom::Ax1
Definition: Ax1.h:50
Geom::XYZ
Definition: XYZ.h:44
Geom::Dir::setZ
void setZ(const double Z)
Assigns the given value to the Z coordinate of this unit vector.
Geom::Dir
Definition: Dir.h:45
Geom::Dir::crossCrossed
Dir crossCrossed(const Dir &V1, const Dir &V2) const
Geom::Dir::z
double z() const
Returns the Z coordinate for a unit vector.
Geom::Dir::operator[]
double & operator[](int i)
Geom::Dir::mirror
void mirror(const Geom::Ax2 &A2)
Geom::Dir::isParallel
bool isParallel(const Dir &Other, const double AngularTolerance) const
Geom::Dir::rotate
void rotate(const Geom::Ax1 &A1, const double Ang)
Geom::Dir::setCoord
void setCoord(const double Xv, const double Yv, const double Zv)
Geom::Dir::Dir
Dir(const Geom::Vec &V)
Normalizes the vector V and creates a direction. Raises ConstructionError if V.Magnitude() <= Resolut...
Geom::Dir::setX
void setX(const double X)
Assigns the given value to the X coordinate of this unit vector.
Geom::Ax2
Definition: Ax2.h:66
Geom::Dir::ZDir
static Dir ZDir()
Definition: Dir.h:76
Geom::Dir::transformed
Dir transformed(const Geom::Trsf &T) const
Geom::Dir::operator-
Dir operator-() const
Definition: Dir.h:200
Geom::Dir::Dir
Dir(const double Xv, const double Yv, const double Zv)
Z
Z
Definition: Globals.h:31
Geom::Dir::coord
double coord(const int Index) const
Geom::Dir::dot
double dot(const Dir &Other) const
Computes the scalar product
Geom::Dir::x
double x() const
Returns the X coordinate for a unit vector.
Geom::Dir::Dir
Dir(const Geom::XYZ &Coord)
Creates a direction from a triplet of coordinates. Raises ConstructionError if Coord....
Geom::Dir::angle
double angle(const Dir &Other) const
Geom::Dir::XDir
static Dir XDir()
Definition: Dir.h:74
Y
Y
Definition: Globals.h:30
Geom::Dir::coord
void coord(double &Xv, double &Yv, double &Zv) const
Returns for the unit vector its three coordinates Xv, Yv, and Zv.
Geom::Dir::YDir
static Dir YDir()
Definition: Dir.h:75
Geom::Dir::reversed
Dir reversed() const
Geom::Dir::y
double y() const
Returns the Y coordinate for a unit vector.
Geom::Dir::operator^
Dir operator^(const Dir &Right) const
Definition: Dir.h:169
Geom::Trsf
Definition: Trsf.h:58
Geom::Dir::isNormal
bool isNormal(const Dir &Other, const double AngularTolerance) const
Returns True if the angle between this unit vector and the unit vector Other is equal to Pi/2 (normal...
Geom::Dir::operator[]
const double & operator[](int i) const
Geom::to_string
LX_GEOM_EXPORT QString to_string(const Dir &dir)
Geom::Dir::crossCross
void crossCross(const Dir &V1, const Dir &V2)
Geom::Dir::Dir
Dir(const Dir &rhs)
Copy constructor.
Geom::Dir::operator^=
void operator^=(const Dir &Right)
Definition: Dir.h:161
Geom::Dir::setCoord
void setCoord(const int Index, const double Xi)
Geom::Dir::mirrored
Dir mirrored(const Dir &V) const
Geom
Definition: PropertyContainer.h:33
Geom::Dir::mirrored
Dir mirrored(const Geom::Ax2 &A2) const