OpenLexocad  27.1
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 namespace Geom
25 {
26 class XYZ;
27 class Trsf;
28 class GTrsf;
29 } // namespace Geom
30 
31 class gp_GTrsf;
32 
33 
34 namespace Geom
35 {
38 class LX_GEOM_EXPORT Mat
39 {
40 public:
42  // //
43  // --------------------- BEGIN API --------------------- //
44  // //
45  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
46  // //
48 
50  Mat();
51 
52  Mat(const double a11,
53  const double a12,
54  const double a13,
55  const double a21,
56  const double a22,
57  const double a23,
58  const double a31,
59  const double a32,
60  const double a33);
63  Mat(const XYZ& Col1, const XYZ& Col2, const XYZ& Col3);
67  void setCol(const int Col, const XYZ& Value);
70  void setCols(const XYZ& Col1, const XYZ& Col2, const XYZ& Col3);
71 
80  void setCross(const XYZ& Ref);
81 
87  void setDiagonal(const double X1, const double X2, const double X3);
88 
94  void setDot(const XYZ& Ref);
96  void setIdentity();
98  bool isIdentity() const;
99 
104  void setRotation(const XYZ& Axis, const double Ang);
107  void setRow(const int Row, const XYZ& Value);
110  void setRows(const XYZ& Row1, const XYZ& Row2, const XYZ& Row3);
111 
117  void setScale(const double S);
120  void setValue(const int Row, const int Col, const double Value);
123  XYZ column(const int Col) const;
125  double determinant() const;
127  XYZ diagonal() const;
130  XYZ row(const int Row) const;
133  const double& value(const int Row, const int Col) const;
134 
135  const double& operator()(const int Row, const int Col) const { return value(Row, Col); }
136 
139  double& changeValue(const int Row, const int Col);
140 
141  double& operator()(const int Row, const int Col) { return changeValue(Row, Col); }
142 
146  bool isSingular() const;
147 
148  void add(const Mat& Other);
149 
150  void operator+=(const Mat& Other) { add(Other); }
151 
155  Mat added(const Mat& Other) const;
156 
157  Mat operator+(const Mat& Other) const { return added(Other); }
158 
159  void divide(const double Scalar);
160 
161  void operator/=(const double Scalar) { divide(Scalar); }
162 
164  Mat divided(const double Scalar) const;
165 
166  Mat operator/(const double Scalar) const { return divided(Scalar); }
167 
168  void invert();
169 
180  Mat inverted() const;
181 
183  Mat multiplied(const Mat& Other) const;
184 
185  Mat operator*(const Mat& Other) const { return multiplied(Other); }
186 
188  void multiply(const Mat& Other);
189 
190  void operator*=(const Mat& Other) { multiply(Other); }
191 
192  void preMultiply(const Mat& Other);
193 
194  Mat multiplied(const double Scalar) const;
195 
196  Mat operator*(const double Scalar) const { return multiplied(Scalar); }
197 
199  void multiply(const double Scalar);
200 
201  void operator*=(const double Scalar) { multiply(Scalar); }
202 
203  void power(const int N);
204 
210  Mat powered(const int N) const;
211 
212  void subtract(const Mat& Other);
213 
214  void operator-=(const Mat& Other) { subtract(Other); }
215 
218  Mat subtracted(const Mat& Other) const;
219 
220  Mat operator-(const Mat& Other) const { return subtracted(Other); }
221 
222  bool operator==(const Mat& Other) const;
223 
224  bool operator!=(const Mat& Other) const { return !(operator==(Other)); }
225 
226  void transpose();
227 
229  Mat transposed() const;
230 
231  friend class XYZ;
232  friend class CA_Transfrom;
233  friend class gp_GTrsf;
234  friend class Geom::GTrsf;
235 
236  Geom::XYZ computeEulerAngles() const;
237 
238  void initFromQuaternion(double w, double x, double y, double z);
239 
240  bool toQuaternion(double& w, double& x, double& y, double& z);
241 
243  // //
244  // ---------------------- END API ---------------------- //
245  // //
247 
248 private:
249  double matrix[3][3];
250 };
251 } // namespace Geom
double & operator()(const int Row, const int Col)
Definition: Mat.h:141
Definition: Variant.h:60
const double & operator()(const int Row, const int Col) const
Definition: Mat.h:135
void operator+=(const Mat &Other)
Definition: Mat.h:150
Vector3f & operator *=(Vector3f &rclVect, const Matrix4D &rclMtrx)
Definition: Matrix.h:351
Definition: Mat.h:38
bool operator!=(const Mat &Other) const
Definition: Mat.h:224
void operator/=(const double Scalar)
Definition: Mat.h:161
Definition: XYZ.h:43
void operator-=(const Mat &Other)
Definition: Mat.h:214
Definition: GTrsf.h:47
Mat operator+(const Mat &Other) const
Definition: Mat.h:157
Mat operator-(const Mat &Other) const
Definition: Mat.h:220
Mat operator/(const double Scalar) const
Definition: Mat.h:166
DualNumber operator *(DualNumber a, DualNumber b)
Definition: DualNumber.h:71