OpenLexocad  27.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 
26 #include <Geom/GeomEnums.h>
27 #include <Geom/XYZ.h>
28 #include <Geom/geom_defines.h>
29 
30 namespace Geom
31 {
32 class Ax1;
33 class Ax2;
34 class Trsf;
35 class Vec;
36 class Dir;
37 
38 
47 {
48 public:
50  // //
51  // --------------------- BEGIN API --------------------- //
52  // //
53  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
54  // //
56 
57  // Methods PUBLIC
58  //
60  Dir();
62  Dir(const Geom::Vec& V);
64  Dir(const Geom::XYZ& Coord);
71  Dir(const double Xv, const double Yv, const double Zv);
73  Dir(const Dir& rhs);
74 
75  // named constr.
76  static Dir XDir() { return Dir(1, 0, 0); };
77  static Dir YDir() { return Dir(0, 1, 0); };
78  static Dir ZDir() { return Dir(0, 0, 1); };
79 
96  void setCoord(const int Index, const double Xi);
100  void setCoord(const double Xv, const double Yv, const double Zv);
102  void setX(const double X);
104  void setY(const double Y);
106  void setZ(const double Z);
108  void setXYZ(const Geom::XYZ& Coord);
109 
116  double coord(const int Index) const;
118  void coord(double& Xv, double& Yv, double& Zv) const;
120  double x() const;
122  double y() const;
124  double z() const;
126  const Geom::XYZ& xyz() const;
127 
130  bool isEqual(const Dir& Other, const double AngularTolerance) const;
131 
133  bool isNormal(const Dir& Other, const double AngularTolerance) const;
134 
136  bool isOpposite(const Dir& Other, const double AngularTolerance) const;
137 
141  bool isParallel(const Dir& Other, const double AngularTolerance) const;
142 
143 
147  double angle(const Dir& Other) const;
148 
149 
157  double angleWithRef(const Dir& Other, const Dir& VRef) const;
162  void cross(const Dir& Right);
163  void operator^=(const Dir& Right) { cross(Right); }
164 
170  Dir crossed(const Dir& Right) const;
171  Dir operator^(const Dir& Right) const { return crossed(Right); }
172 
173 
174  void crossCross(const Dir& V1, const Dir& V2);
183  Dir crossCrossed(const Dir& V1, const Dir& V2) const;
185  double dot(const Dir& Other) const;
186  double operator*(const Dir& Other) const { return dot(Other); }
187 
188 
194  double dotCross(const Dir& V1, const Dir& V2) const;
195 
196  void reverse();
201  Dir reversed() const;
202  Dir operator-() const { return reversed(); }
203 
204 
205 
206  void mirror(const Dir& V);
207 
208 
212  Dir mirrored(const Dir& V) const;
213 
214 
215  void mirror(const Geom::Ax1& A1);
216 
217 
221  Dir mirrored(const Geom::Ax1& A1) const;
222 
223 
224  void mirror(const Geom::Ax2& A2);
225 
226 
230  Dir mirrored(const Geom::Ax2& A2) const;
231 
232  void rotate(const Geom::Ax1& A1, const double Ang);
233 
236  Dir rotated(const Geom::Ax1& A1, const double Ang) const;
237 
238 
239  void transform(const Geom::Trsf& T);
240 
245  Dir transformed(const Geom::Trsf& T) const;
246 
248  // //
249  // ---------------------- END API ---------------------- //
250  // //
252 
254  bool operator==(const Geom::Dir& other) const;
255 
256 
257  double& operator[](int i);
258  const double& operator[](int i) const;
259 
260 
261 private:
262  Geom::XYZ _coord;
263 };
264 
265 } // namespace Geom
Definition: Rotation.h:5
X
Definition: Globals.h:32
static Dir YDir()
Definition: Dir.h:77
void operator^=(const Dir &Right)
Definition: Dir.h:163
#define GEOM_EXPORT
Definition: geom_defines.h:8
static Dir XDir()
Definition: Dir.h:76
static Dir ZDir()
Definition: Dir.h:78
Definition: Ax2.h:69
Definition: XYZ.h:46
Definition: Trsf.h:58
Definition: Dir.h:46
Dir operator^(const Dir &Right) const
Definition: Dir.h:171
Y
Definition: Globals.h:32
Definition: Ax1.h:52
Z
Definition: Globals.h:32
Defines a non-persistent vector in 3D space.
Definition: Vec.h:45
Geom::Vec operator *(const double Scalar, const Geom::Vec &V)
Definition: Vec.h:312
Dir operator-() const
Definition: Dir.h:202