OpenLexocad  28.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 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
Geom::XY::crossSquareMagnitude
double crossSquareMagnitude(const XY &Right) const
Geom::XY::multiply
void multiply(const double Scalar)
Geom::XY::multiplied
XY multiplied(const double Scalar) const
Geom::XY::x
double x() const
Returns the x coordinate of this number pair.
Geom::XY::isEqual
bool isEqual(const XY &Other, const double Tolerance) const
Geom::XY::operator*
double operator*(const XY &Other) const
Definition: XY.h:116
Geom::XY::multiply
void multiply(const XY &Other)
Geom::XY::reversed
XY reversed() const
Geom::XY::operator+=
void operator+=(const XY &Other)
Definition: XY.h:105
Geom::XY::normalize
void normalize()
X
X
Definition: Globals.h:29
Geom::XY::operator/
XY operator/(const double Scalar) const
Definition: XY.h:126
Geom::XY::XY
XY()
Creates an indefinite XY number pair.
Geom::XY::operator*=
void operator*=(const XY &Other)
Definition: XY.h:120
Geom::XY::XY
XY(const double X, const double Y)
a number pair defined by the XY coordinates
Geom::XY::crossMagnitude
double crossMagnitude(const XY &Right) const
Geom::XY::operator/=
void operator/=(const double Scalar)
Definition: XY.h:125
Geom::XY::reverse
void reverse()
Geom::XY::coord
double coord(const int Index) const
Geom::XY
Definition: XY.h:34
Geom::XY::y
double y() const
Returns the y coordinate of this number pair.
Geom::XY::operator*=
void operator*=(const double Scalar)
Definition: XY.h:118
Geom::XY::operator*
XY operator*(const Mat2d &Matrix) const
Definition: XY.h:114
Geom::XY::subtract
void subtract(const XY &Right)
Geom::XY::setY
void setY(const double Y)
Assigns the given value to the Y coordinate of this number pair.
Geom::Mat2d
Definition: Mat2d.h:34
Geom::XY::operator-
XY operator-() const
Definition: XY.h:108
Geom::XY::operator+
XY operator+(const XY &Other) const
Definition: XY.h:106
Geom::XY::multiplied
XY multiplied(const XY &Other) const
Geom::XY::setLinearForm
void setLinearForm(const XY &XY1, const XY &XY2)
Geom::XY::dot
double dot(const XY &Other) const
Computes the scalar product between <me> and Other
Geom::XY::operator-=
void operator-=(const XY &Right)
Definition: XY.h:110
Geom::XY::divided
XY divided(const double Scalar) const
Divides <me> by a real.
Geom::XY::multiplied
XY multiplied(const Mat2d &Matrix) const
New = Matrix * <me>
Geom::XY::setX
void setX(const double X)
Assigns the given value to the X coordinate of this number pair.
Geom::XY::squareModulus
double squareModulus() const
Computes x*x + y*y where x and y are the two coordinates of this number pair.
Y
Y
Definition: Globals.h:30
Geom::XY::operator-
XY operator-(const XY &Right) const
Definition: XY.h:112
Geom::XY::coord
void coord(double &X, double &Y) const
For this number pair, returns its coordinates X and Y.
Geom::XY::setCoord
void setCoord(const double X, const double Y)
Geom::XY::added
XY added(const XY &Other) const
Geom::XY::modulus
double modulus() const
Computes Sqrt (x*x + y*y) where x and y are the two coordinates of this number pair.
Geom::XY::add
void add(const XY &Other)
Geom::XY::normalized
XY normalized() const
Geom::XY::multiply
void multiply(const Mat2d &Matrix)
<me> = Matrix * <me>
Geom::XY::setLinearForm
void setLinearForm(const double A1, const XY &XY1, const double A2, const XY &XY2, const XY &XY3)
Geom::XY::divide
void divide(const double Scalar)
divides <me> by a real.
Geom::XY::setCoord
void setCoord(const int Index, const double Xi)
Geom::XY::setLinearForm
void setLinearForm(const double A1, const XY &XY1, const XY &XY2)
Geom::XY::crossed
double crossed(const XY &Right) const
Real D = <me>.x() * Other.y() - <me>.y() * Other.x()
Geom::XY::operator^
double operator^(const XY &Right) const
Definition: XY.h:127
Geom::XY::operator*
XY operator*(const double Scalar) const
Definition: XY.h:123
Geom::XY::operator*=
void operator*=(const Mat2d &Matrix)
Definition: XY.h:121
Geom::XY::subtracted
XY subtracted(const XY &Right) const
Geom
Definition: PropertyContainer.h:33
Geom::XY::setLinearForm
void setLinearForm(const double A1, const XY &XY1, const double A2, const XY &XY2)