OpenLexocad  27.0
XY.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 #include <Geom/geom_defines.h>
24 
25 namespace Geom
26 {
27 class Mat2d;
28 
36 {
37 public:
39  XY();
41  XY(const double X, const double Y);
42 
46  void add(const XY& Other);
50  XY added(const XY& Other) const;
55  double coord(const int Index) const;
57  void coord(double& X, double& Y) const;
59  double crossed(const XY& Right) const;
62  double crossMagnitude(const XY& Right) const;
63 
66  double crossSquareMagnitude(const XY& Right) const;
68  void divide(const double Scalar);
70  XY divided(const double Scalar) const;
72  double dot(const XY& Other) const;
78  bool isEqual(const XY& Other, const double Tolerance) const;
80  double modulus() const;
83  XY multiplied(const double Scalar) const;
86  XY multiplied(const XY& Other) const;
88  XY multiplied(const Mat2d& Matrix) const;
91  void multiply(const double Scalar);
94  void multiply(const XY& Other);
96  void multiply(const Mat2d& Matrix);
100  void normalize();
101 
105  XY normalized() const;
106 
107  void operator+=(const XY& Other) { add(Other); }
108  XY operator+(const XY& Other) const { return added(Other); }
109 
110  XY operator-() const { return reversed(); }
111 
112  void operator-=(const XY& Right) { subtract(Right); }
113 
114  XY operator-(const XY& Right) const { return subtracted(Right); }
115 
116  XY operator*(const Mat2d& Matrix) const { return multiplied(Matrix); }
117 
118  double operator*(const XY& Other) const { return dot(Other); }
119 
120  void operator*=(const double Scalar) { multiply(Scalar); }
121 
122  void operator*=(const XY& Other) { multiply(Other); }
123  void operator*=(const Mat2d& Matrix) { multiply(Matrix); }
124 
125  XY operator*(const double Scalar) const { return multiplied(Scalar); }
126 
127  void operator/=(const double Scalar) { divide(Scalar); }
128  XY operator/(const double Scalar) const { return divided(Scalar); }
129  double operator^(const XY& Right) const { return crossed(Right); }
130 
133  void reverse();
134 
137  XY reversed() const;
142  void setCoord(const int Index, const double Xi);
145  void setCoord(const double X, const double Y);
149  void setLinearForm(const double A1, const XY& XY1, const double A2, const XY& XY2);
150 
154  void setLinearForm(const double A1, const XY& XY1, const double A2, const XY& XY2, const XY& XY3);
155 
159  void setLinearForm(const double A1, const XY& XY1, const XY& XY2);
160 
164  void setLinearForm(const XY& XY1, const XY& XY2);
165 
167  void setX(const double X);
169  void setY(const double Y);
170 
172  double squareModulus() const;
173 
176  void subtract(const XY& Right);
179  XY subtracted(const XY& Right) const;
181  double x() const;
183  double y() const;
184 
185 protected:
186 private:
187  double _x;
188  double _y;
189 };
190 
191 } // namespace Geom
Definition: Rotation.h:5
X
Definition: Globals.h:32
Definition: XY.h:35
Definition: Mat2d.h:35
#define GEOM_EXPORT
Definition: geom_defines.h:8
void operator+=(const XY &Other)
Definition: XY.h:107
void operator/=(const double Scalar)
Definition: XY.h:127
Y
Definition: Globals.h:32
XY operator/(const double Scalar) const
Definition: XY.h:128
XY operator-(const XY &Right) const
Definition: XY.h:114
Geom::Vec operator *(const double Scalar, const Geom::Vec &V)
Definition: Vec.h:312
XY operator+(const XY &Other) const
Definition: XY.h:108
void operator-=(const XY &Right)
Definition: XY.h:112
XY operator-() const
Definition: XY.h:110
double operator^(const XY &Right) const
Definition: XY.h:129