OpenLexocad  27.1
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/XYZ.h>
27 #include <QString>
28 
29 namespace Geom
30 {
31 class Ax1;
32 class Ax2;
33 class Trsf;
34 class Vec;
35 class Dir;
36 
37 
45 class LX_GEOM_EXPORT Dir
46 {
47 public:
49  // //
50  // --------------------- BEGIN API --------------------- //
51  // //
52  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
53  // //
55 
56  // Methods PUBLIC
57  //
59  Dir();
61  Dir(const Geom::Vec& V);
63  Dir(const Geom::XYZ& Coord);
70  Dir(const double Xv, const double Yv, const double Zv);
72  Dir(const Dir& rhs);
73 
74  // named constr.
75  static Dir XDir() { return Dir(1, 0, 0); };
76  static Dir YDir() { return Dir(0, 1, 0); };
77  static Dir ZDir() { return Dir(0, 0, 1); };
78 
95  void setCoord(const int Index, const double Xi);
99  void setCoord(const double Xv, const double Yv, const double Zv);
101  void setX(const double X);
103  void setY(const double Y);
105  void setZ(const double Z);
107  void setXYZ(const Geom::XYZ& Coord);
108 
115  double coord(const int Index) const;
117  void coord(double& Xv, double& Yv, double& Zv) const;
119  double x() const;
121  double y() const;
123  double z() const;
125  const Geom::XYZ& xyz() const;
126 
129  bool isEqual(const Dir& Other, const double AngularTolerance) const;
130 
132  bool isNormal(const Dir& Other, const double AngularTolerance) const;
133 
135  bool isOpposite(const Dir& Other, const double AngularTolerance) const;
136 
140  bool isParallel(const Dir& Other, const double AngularTolerance) const;
141 
142 
146  double angle(const Dir& Other) const;
147 
148 
156  double angleWithRef(const Dir& Other, const Dir& VRef) const;
161  void cross(const Dir& Right);
162  void operator^=(const Dir& Right) { cross(Right); }
163 
169  Dir crossed(const Dir& Right) const;
170  Dir operator^(const Dir& Right) const { return crossed(Right); }
171 
172 
173  void crossCross(const Dir& V1, const Dir& V2);
182  Dir crossCrossed(const Dir& V1, const Dir& V2) const;
184  double dot(const Dir& Other) const;
185  double operator*(const Dir& Other) const { return dot(Other); }
186 
187 
193  double dotCross(const Dir& V1, const Dir& V2) const;
194 
195  void reverse();
200  Dir reversed() const;
201  Dir operator-() const { return reversed(); }
202 
203 
204 
205  void mirror(const Dir& V);
206 
207 
211  Dir mirrored(const Dir& V) const;
212 
213 
214  void mirror(const Geom::Ax1& A1);
215 
216 
220  Dir mirrored(const Geom::Ax1& A1) const;
221 
222 
223  void mirror(const Geom::Ax2& A2);
224 
225 
229  Dir mirrored(const Geom::Ax2& A2) const;
230 
231  void rotate(const Geom::Ax1& A1, const double Ang);
232 
235  Dir rotated(const Geom::Ax1& A1, const double Ang) const;
236 
237 
238  void transform(const Geom::Trsf& T);
239 
244  Dir transformed(const Geom::Trsf& T) const;
245 
247  // //
248  // ---------------------- END API ---------------------- //
249  // //
251 
253  bool operator==(const Geom::Dir& other) const;
254 
255 
256  double& operator[](int i);
257  const double& operator[](int i) const;
258 
259 
260 private:
261  Geom::XYZ _coord;
262 };
263  LX_GEOM_EXPORT QString to_string(const Dir& dir);
264 
265 } // namespace Geom
Definition: Variant.h:60
X
Definition: Globals.h:29
static Dir YDir()
Definition: Dir.h:76
void operator^=(const Dir &Right)
Definition: Dir.h:162
static Dir XDir()
Definition: Dir.h:75
void transform(Container container, OutputIt out, BinaryFunction function)
Definition: Algorithms.h:29
static Dir ZDir()
Definition: Dir.h:77
Definition: Ax2.h:67
Definition: XYZ.h:43
Definition: Trsf.h:57
Definition: Dir.h:45
Dir operator^(const Dir &Right) const
Definition: Dir.h:170
Y
Definition: Globals.h:29
LX_GEOM_EXPORT QString to_string(const Dir &dir)
Definition: Ax1.h:50
Z
Definition: Globals.h:29
Defines a non-persistent vector in 3D space.
Definition: Vec.h:44
Dir operator-() const
Definition: Dir.h:201
DualNumber operator *(DualNumber a, DualNumber b)
Definition: DualNumber.h:71