OpenLexocad  27.1
Dir2d.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 #pragma once
23 
24 #include <Geom/Precision.h>
25 #include <Geom/Trsf2d.h>
26 #include <Geom/XY.h>
27 
28 namespace Geom
29 {
38 class LX_GEOM_EXPORT Dir2d
39 {
40 public:
42  Dir2d();
44  Dir2d(const Vec2d& V);
46  Dir2d(const XY& Coord);
48  Dir2d(const double Xv, const double Yv);
49 
52  double angle(const Dir2d& Other) const;
53 
58  double coord(const int Index) const;
61  void coord(double& Xv, double& Yv) const;
63  double crossed(const Dir2d& Right) const;
65  double dot(const Dir2d& Other) const;
69  bool isEqual(const Dir2d& Other, const double AngularTolerance) const;
70 
74  bool isNormal(const Dir2d& Other, const double AngularTolerance) const;
75 
79  bool isOpposite(const Dir2d& Other, const double AngularTolerance) const;
80 
85  bool isParallel(const Dir2d& Other, const double AngularTolerance) const;
86 
87  void mirror(const Dir2d& V);
88 
89  void mirror(const Ax2d& A);
90 
94  Dir2d mirrored(const Ax2d& A) const;
95 
99  Dir2d mirrored(const Dir2d& V) const;
100 
101  Dir2d operator-() const { return reversed(); }
102 
103  double operator^(const Dir2d& Right) const { return crossed(Right); }
104  double operator*(const Dir2d& Other) const { return dot(Other); }
105 
106  bool operator==(const Dir2d& other) const { return _coord.isEqual(other._coord, Geom::Precision::epsilon()); }
107 
108  void reverse();
110  Dir2d reversed() const;
111  void rotate(const double Ang);
112 
115  Dir2d rotated(const double Ang) const;
116 
133  void setCoord(const int Index, const double Xi);
134 
149  void setCoord(const double Xv, const double Yv);
150 
163  void setX(const double X);
164 
178  void setXY(const XY& Coord);
179 
192  void setY(const double Y);
193 
194  void transform(const Trsf2d& T);
195 
200  Dir2d transformed(const Trsf2d& T) const;
201 
203  double x() const;
206  const XY& xy() const;
207 
209  double y() const;
210 
211 protected:
212 private:
213  XY _coord;
214 };
215 } // namespace Geom
bool operator==(const Dir2d &other) const
Definition: Dir2d.h:106
Definition: Variant.h:60
X
Definition: Globals.h:29
Definition: XY.h:33
static double epsilon()
Definition: Precision.h:64
Definition: Ax2d.h:48
Dir2d operator-() const
Definition: Dir2d.h:101
Definition: Dir2d.h:38
void transform(Container container, OutputIt out, BinaryFunction function)
Definition: Algorithms.h:29
Y
Definition: Globals.h:29
Defines a non-persistent vector in 2D space.
Definition: Vec2d.h:34
Definition: Trsf2d.h:46
DualNumber operator *(DualNumber a, DualNumber b)
Definition: DualNumber.h:71
double operator^(const Dir2d &Right) const
Definition: Dir2d.h:103