OpenLexocad  28.0
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/XY.h> // for XY
26 
27 namespace Geom { class Ax2d; }
28 namespace Geom { class Trsf2d; }
29 namespace Geom { class Vec2d; }
30 
31 namespace Geom
32 {
41 class LX_GEOM_EXPORT Dir2d
42 {
43 public:
45  Dir2d();
47  Dir2d(const Vec2d& V);
49  Dir2d(const XY& Coord);
51  Dir2d(const double Xv, const double Yv);
52 
55  double angle(const Dir2d& Other) const;
56 
61  double coord(const int Index) const;
64  void coord(double& Xv, double& Yv) const;
66  double crossed(const Dir2d& Right) const;
68  double dot(const Dir2d& Other) const;
72  bool isEqual(const Dir2d& Other, const double AngularTolerance) const;
73 
77  bool isNormal(const Dir2d& Other, const double AngularTolerance) const;
78 
82  bool isOpposite(const Dir2d& Other, const double AngularTolerance) const;
83 
88  bool isParallel(const Dir2d& Other, const double AngularTolerance) const;
89 
90  void mirror(const Dir2d& V);
91 
92  void mirror(const Ax2d& A);
93 
97  Dir2d mirrored(const Ax2d& A) const;
98 
102  Dir2d mirrored(const Dir2d& V) const;
103 
104  Dir2d operator-() const { return reversed(); }
105 
106  double operator^(const Dir2d& Right) const { return crossed(Right); }
107  double operator*(const Dir2d& Other) const { return dot(Other); }
108 
109  bool operator==(const Dir2d& other) const { return _coord.isEqual(other._coord, Geom::Precision::epsilon()); }
110 
111  void reverse();
113  Dir2d reversed() const;
114  void rotate(const double Ang);
115 
118  Dir2d rotated(const double Ang) const;
119 
136  void setCoord(const int Index, const double Xi);
137 
152  void setCoord(const double Xv, const double Yv);
153 
166  void setX(const double X);
167 
181  void setXY(const XY& Coord);
182 
195  void setY(const double Y);
196 
197  void transform(const Trsf2d& T);
198 
203  Dir2d transformed(const Trsf2d& T) const;
204 
206  double x() const;
209  const XY& xy() const;
210 
212  double y() const;
213 
214 protected:
215 private:
216  XY _coord;
217 };
218 } // namespace Geom
Geom::Dir2d::Dir2d
Dir2d()
Creates an indefinite Direction.
Geom::Dir2d::setXY
void setXY(const XY &Coord)
Geom::Precision::epsilon
static constexpr double epsilon()
Definition: Precision.h:63
Geom::Dir2d::isNormal
bool isNormal(const Dir2d &Other, const double AngularTolerance) const
Geom::Dir2d::xy
const XY & xy() const
Geom::Dir2d::Dir2d
Dir2d(const XY &Coord)
Creates a Direction from a doublet of coordinates. Raises ConstructionError if Coord....
Precision.h
Geom::Dir2d::rotated
Dir2d rotated(const double Ang) const
Geom::Dir2d::crossed
double crossed(const Dir2d &Right) const
Computes the cross product between two directions.
Geom::Dir2d::operator^
double operator^(const Dir2d &Right) const
Definition: Dir2d.h:106
Geom::Dir2d::operator*
double operator*(const Dir2d &Other) const
Definition: Dir2d.h:107
XY.h
X
X
Definition: Globals.h:29
Geom::Dir2d::isParallel
bool isParallel(const Dir2d &Other, const double AngularTolerance) const
Geom::Dir2d::mirrored
Dir2d mirrored(const Ax2d &A) const
Geom::Dir2d::mirrored
Dir2d mirrored(const Dir2d &V) const
Geom::XY
Definition: XY.h:34
Geom::Dir2d::Dir2d
Dir2d(const Vec2d &V)
Normalizes the vector V and creates a Direction. Raises ConstructionError if V.Magnitude() <= Resolut...
Geom::Dir2d::mirror
void mirror(const Ax2d &A)
Geom::Dir2d::x
double x() const
For this unit vector, returns its x coordinate.
Geom::Dir2d::transformed
Dir2d transformed(const Trsf2d &T) const
Geom::Dir2d
Definition: Dir2d.h:42
Geom::Dir2d::angle
double angle(const Dir2d &Other) const
Geom::Dir2d::operator==
bool operator==(const Dir2d &other) const
Definition: Dir2d.h:109
Geom::Dir2d::coord
void coord(double &Xv, double &Yv) const
Geom::Dir2d::dot
double dot(const Dir2d &Other) const
Computes the scalar product
Geom::Dir2d::isOpposite
bool isOpposite(const Dir2d &Other, const double AngularTolerance) const
Geom::Dir2d::setX
void setX(const double X)
Geom::Vec2d
Defines a non-persistent vector in 2D space.
Definition: Vec2d.h:33
Geom::Dir2d::operator-
Dir2d operator-() const
Definition: Dir2d.h:104
Geom::Ax2d
Definition: Ax2d.h:51
Geom::Dir2d::reversed
Dir2d reversed() const
Reverses the orientation of a direction
Y
Y
Definition: Globals.h:30
Geom::Dir2d::mirror
void mirror(const Dir2d &V)
Geom::Dir2d::transform
void transform(const Trsf2d &T)
Geom::Dir2d::isEqual
bool isEqual(const Dir2d &Other, const double AngularTolerance) const
Geom::Dir2d::Dir2d
Dir2d(const double Xv, const double Yv)
Creates a Direction with its 2 cartesian coordinates. Raises ConstructionError if Sqrt(Xv*Xv + Yv*Yv)...
Geom::Dir2d::coord
double coord(const int Index) const
Geom::Trsf2d
Definition: Trsf2d.h:47
Geom::Dir2d::reverse
void reverse()
Geom::Dir2d::setCoord
void setCoord(const int Index, const double Xi)
Geom::Dir2d::setCoord
void setCoord(const double Xv, const double Yv)
Geom::Dir2d::rotate
void rotate(const double Ang)
Geom::Dir2d::setY
void setY(const double Y)
Geom::Dir2d::y
double y() const
For this unit vector, returns its y coordinate.
Geom
Definition: PropertyContainer.h:33