OpenLexocad  27.1
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 namespace Geom
24 {
25 class Mat2d;
26 
33 class LX_GEOM_EXPORT XY
34 {
35 public:
37  XY();
39  XY(const double X, const double Y);
40 
44  void add(const XY& Other);
48  XY added(const XY& Other) const;
53  double coord(const int Index) const;
55  void coord(double& X, double& Y) const;
57  double crossed(const XY& Right) const;
60  double crossMagnitude(const XY& Right) const;
61 
64  double crossSquareMagnitude(const XY& Right) const;
66  void divide(const double Scalar);
68  XY divided(const double Scalar) const;
70  double dot(const XY& Other) const;
76  bool isEqual(const XY& Other, const double Tolerance) const;
78  double modulus() const;
81  XY multiplied(const double Scalar) const;
84  XY multiplied(const XY& Other) const;
86  XY multiplied(const Mat2d& Matrix) const;
89  void multiply(const double Scalar);
92  void multiply(const XY& Other);
94  void multiply(const Mat2d& Matrix);
98  void normalize();
99 
103  XY normalized() const;
104 
105  void operator+=(const XY& Other) { add(Other); }
106  XY operator+(const XY& Other) const { return added(Other); }
107 
108  XY operator-() const { return reversed(); }
109 
110  void operator-=(const XY& Right) { subtract(Right); }
111 
112  XY operator-(const XY& Right) const { return subtracted(Right); }
113 
114  XY operator*(const Mat2d& Matrix) const { return multiplied(Matrix); }
115 
116  double operator*(const XY& Other) const { return dot(Other); }
117 
118  void operator*=(const double Scalar) { multiply(Scalar); }
119 
120  void operator*=(const XY& Other) { multiply(Other); }
121  void operator*=(const Mat2d& Matrix) { multiply(Matrix); }
122 
123  XY operator*(const double Scalar) const { return multiplied(Scalar); }
124 
125  void operator/=(const double Scalar) { divide(Scalar); }
126  XY operator/(const double Scalar) const { return divided(Scalar); }
127  double operator^(const XY& Right) const { return crossed(Right); }
128 
131  void reverse();
132 
135  XY reversed() const;
140  void setCoord(const int Index, const double Xi);
143  void setCoord(const double X, const double Y);
147  void setLinearForm(const double A1, const XY& XY1, const double A2, const XY& XY2);
148 
152  void setLinearForm(const double A1, const XY& XY1, const double A2, const XY& XY2, const XY& XY3);
153 
157  void setLinearForm(const double A1, const XY& XY1, const XY& XY2);
158 
162  void setLinearForm(const XY& XY1, const XY& XY2);
163 
165  void setX(const double X);
167  void setY(const double Y);
168 
170  double squareModulus() const;
171 
174  void subtract(const XY& Right);
177  XY subtracted(const XY& Right) const;
179  double x() const;
181  double y() const;
182 
183 protected:
184 private:
185  double _x;
186  double _y;
187 };
188 
189 } // namespace Geom
Definition: Variant.h:60
X
Definition: Globals.h:29
Definition: XY.h:33
Vector3f & operator *=(Vector3f &rclVect, const Matrix4D &rclMtrx)
Definition: Matrix.h:351
Definition: Mat2d.h:33
void operator+=(const XY &Other)
Definition: XY.h:105
void operator/=(const double Scalar)
Definition: XY.h:125
Y
Definition: Globals.h:29
XY operator/(const double Scalar) const
Definition: XY.h:126
XY operator-(const XY &Right) const
Definition: XY.h:112
XY operator+(const XY &Other) const
Definition: XY.h:106
void operator-=(const XY &Right)
Definition: XY.h:110
DualNumber operator *(DualNumber a, DualNumber b)
Definition: DualNumber.h:71
XY operator-() const
Definition: XY.h:108
double operator^(const XY &Right) const
Definition: XY.h:127