OpenLexocad  27.1
Mat2d.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 
25 namespace Geom
26 {
27 class GTrsf2d;
28 class Trsf2d;
29 class XY;
30 
33 class LX_GEOM_EXPORT Mat2d
34 {
35 public:
37  Mat2d();
38 
40  Mat2d(const XY& Col1, const XY& Col2);
41  void add(const Mat2d& Other);
48  Mat2d added(const Mat2d& Other) const;
52  double& changeValue(const int Row, const int Col);
55  XY column(const int Col) const;
57  double determinant() const;
59  XY diagonal() const;
60  void divide(const double Scalar);
62  Mat2d divided(const double Scalar) const;
63  void invert();
64 
67  Mat2d inverted() const;
68 
69  static inline bool isEven(const int Value) { return Value % 2 == 0; }
70 
71  static inline bool isOdd(const int Value) { return Value % 2 != 0; }
76  bool isSingular() const;
77 
78  Mat2d multiplied(const Mat2d& Other) const;
80  void multiply(const Mat2d& Other);
81  Mat2d multiplied(const double Scalar) const;
83  void multiply(const double Scalar);
84  void operator+=(const Mat2d& Other) { add(Other); }
85 
86  Mat2d operator+(const Mat2d& Other) const { return added(Other); }
87 
88  void operator-=(const Mat2d& Other) { subtract(Other); }
89 
90  Mat2d operator-(const Mat2d& Other) const { return subtracted(Other); }
91 
92  void operator*=(const double Scalar) { multiply(Scalar); }
93 
94  Mat2d operator*(const double Scalar) const { return multiplied(Scalar); }
95 
96  Mat2d operator*(const Mat2d& Other) const { return multiplied(Other); }
97 
98  void operator/=(const double Scalar) { divide(Scalar); }
99 
100  Mat2d operator/(const double Scalar) const { return divided(Scalar); }
101 
102  const double& operator()(const int Row, const int Col) const { return value(Row, Col); }
103  double& operator()(const int Row, const int Col) { return changeValue(Row, Col); }
104 
105  void power(const int N);
106 
112  Mat2d powered(const int N) const;
113 
116  void preMultiply(const Mat2d& Other);
117 
119  XY row(const int Row) const;
123  void setCol(const int Col, const XY& Value);
125  void setCols(const XY& Col1, const XY& Col2);
126 
131  void setDiagonal(const double X1, const double X2);
133  void setIdentity();
134 
137  void setRotation(const double Ang);
140  void setRow(const int Row, const XY& Value);
142  void setRows(const XY& Row1, const XY& Row2);
143 
148  void setScale(const double S);
151  void setValue(const int Row, const int Col, const double Value);
152  void subtract(const Mat2d& Other);
155  Mat2d subtracted(const Mat2d& Other) const;
156  void transpose();
157 
159  Mat2d transposed() const;
160 
164  const double& value(const int Row, const int Col) const;
165  friend class GTrsf2d;
166  friend class Trsf2d;
167  friend class XY;
168 
169 protected:
170 private:
171  double _matrix[2][2];
172 };
173 } // namespace Geom
Definition: Variant.h:60
Definition: XY.h:33
Vector3f & operator *=(Vector3f &rclVect, const Matrix4D &rclMtrx)
Definition: Matrix.h:351
static bool isEven(const int Value)
Definition: Mat2d.h:69
Mat2d operator+(const Mat2d &Other) const
Definition: Mat2d.h:86
static bool isOdd(const int Value)
Definition: Mat2d.h:71
Definition: Mat2d.h:33
void operator/=(const double Scalar)
Definition: Mat2d.h:98
Definition: GTrsf2d.h:48
Definition: Trsf2d.h:46
Mat2d operator-(const Mat2d &Other) const
Definition: Mat2d.h:90
const double & operator()(const int Row, const int Col) const
Definition: Mat2d.h:102
Mat2d operator/(const double Scalar) const
Definition: Mat2d.h:100
void operator-=(const Mat2d &Other)
Definition: Mat2d.h:88
DualNumber operator *(DualNumber a, DualNumber b)
Definition: DualNumber.h:71
double & operator()(const int Row, const int Col)
Definition: Mat2d.h:103
void operator+=(const Mat2d &Other)
Definition: Mat2d.h:84