OpenLexocad  27.0
Mat.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/GeomEnums.h>
25 #include <Geom/geom_defines.h>
26 
27 namespace Geom
28 {
29 class XYZ;
30 class Trsf;
31 class GTrsf;
32 } // namespace Geom
33 
34 class gp_GTrsf;
35 
36 
37 namespace Geom
38 {
42 {
43 public:
45  // //
46  // --------------------- BEGIN API --------------------- //
47  // //
48  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
49  // //
51 
53  Mat();
54 
55  Mat(const double a11,
56  const double a12,
57  const double a13,
58  const double a21,
59  const double a22,
60  const double a23,
61  const double a31,
62  const double a32,
63  const double a33);
66  Mat(const XYZ& Col1, const XYZ& Col2, const XYZ& Col3);
70  void setCol(const int Col, const XYZ& Value);
73  void setCols(const XYZ& Col1, const XYZ& Col2, const XYZ& Col3);
74 
83  void setCross(const XYZ& Ref);
84 
90  void setDiagonal(const double X1, const double X2, const double X3);
91 
97  void setDot(const XYZ& Ref);
99  void setIdentity();
101  bool isIdentity() const;
102 
107  void setRotation(const XYZ& Axis, const double Ang);
110  void setRow(const int Row, const XYZ& Value);
113  void setRows(const XYZ& Row1, const XYZ& Row2, const XYZ& Row3);
114 
120  void setScale(const double S);
123  void setValue(const int Row, const int Col, const double Value);
126  XYZ column(const int Col) const;
128  double determinant() const;
130  XYZ diagonal() const;
133  XYZ row(const int Row) const;
136  const double& value(const int Row, const int Col) const;
137 
138  const double& operator()(const int Row, const int Col) const { return value(Row, Col); }
139 
142  double& changeValue(const int Row, const int Col);
143 
144  double& operator()(const int Row, const int Col) { return changeValue(Row, Col); }
145 
149  bool isSingular() const;
150 
151  void add(const Mat& Other);
152 
153  void operator+=(const Mat& Other) { add(Other); }
154 
158  Mat added(const Mat& Other) const;
159 
160  Mat operator+(const Mat& Other) const { return added(Other); }
161 
162  void divide(const double Scalar);
163 
164  void operator/=(const double Scalar) { divide(Scalar); }
165 
167  Mat divided(const double Scalar) const;
168 
169  Mat operator/(const double Scalar) const { return divided(Scalar); }
170 
171  void invert();
172 
183  Mat inverted() const;
184 
186  Mat multiplied(const Mat& Other) const;
187 
188  Mat operator*(const Mat& Other) const { return multiplied(Other); }
189 
191  void multiply(const Mat& Other);
192 
193  void operator*=(const Mat& Other) { multiply(Other); }
194 
195  void preMultiply(const Mat& Other);
196 
197  Mat multiplied(const double Scalar) const;
198 
199  Mat operator*(const double Scalar) const { return multiplied(Scalar); }
200 
202  void multiply(const double Scalar);
203 
204  void operator*=(const double Scalar) { multiply(Scalar); }
205 
206  void power(const int N);
207 
213  Mat powered(const int N) const;
214 
215  void subtract(const Mat& Other);
216 
217  void operator-=(const Mat& Other) { subtract(Other); }
218 
221  Mat subtracted(const Mat& Other) const;
222 
223  Mat operator-(const Mat& Other) const { return subtracted(Other); }
224 
225  bool operator==(const Mat& Other) const;
226 
227  bool operator!=(const Mat& Other) const { return !(operator==(Other)); }
228 
229  void transpose();
230 
232  Mat transposed() const;
233 
234  friend class XYZ;
235  friend class CA_Transfrom;
236  friend class gp_GTrsf;
237  friend class Geom::GTrsf;
238 
239  Geom::XYZ computeEulerAngles() const;
240 
242  // //
243  // ---------------------- END API ---------------------- //
244  // //
246 
247 private:
248  double matrix[3][3];
249 };
250 } // namespace Geom
double & operator()(const int Row, const int Col)
Definition: Mat.h:144
Definition: Rotation.h:5
const double & operator()(const int Row, const int Col) const
Definition: Mat.h:138
void operator+=(const Mat &Other)
Definition: Mat.h:153
Definition: Mat.h:41
#define GEOM_EXPORT
Definition: geom_defines.h:8
bool operator!=(const Mat &Other) const
Definition: Mat.h:227
void operator/=(const double Scalar)
Definition: Mat.h:164
Definition: XYZ.h:46
void operator-=(const Mat &Other)
Definition: Mat.h:217
Definition: GTrsf.h:49
Geom::Vec operator *(const double Scalar, const Geom::Vec &V)
Definition: Vec.h:312
Mat operator+(const Mat &Other) const
Definition: Mat.h:160
Mat operator-(const Mat &Other) const
Definition: Mat.h:223
Mat operator/(const double Scalar) const
Definition: Mat.h:169