OpenLexocad  28.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 namespace Geom
25 {
26 class XYZ;
27 class GTrsf;
28 } // namespace Geom
29 
30 
31 
32 namespace Geom
33 {
36 class LX_GEOM_EXPORT Mat
37 {
38 public:
40  // //
41  // --------------------- BEGIN API --------------------- //
42  // //
43  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
44  // //
46 
48  Mat();
49 
50  Mat(const double a11,
51  const double a12,
52  const double a13,
53  const double a21,
54  const double a22,
55  const double a23,
56  const double a31,
57  const double a32,
58  const double a33);
61  Mat(const XYZ& Col1, const XYZ& Col2, const XYZ& Col3);
65  void setCol(const int Col, const XYZ& Value);
68  void setCols(const XYZ& Col1, const XYZ& Col2, const XYZ& Col3);
69 
78  void setCross(const XYZ& Ref);
79 
85  void setDiagonal(const double X1, const double X2, const double X3);
86 
92  void setDot(const XYZ& Ref);
94  void setIdentity();
96  bool isIdentity() const;
97 
102  void setRotation(const XYZ& Axis, const double Ang);
105  void setRow(const int Row, const XYZ& Value);
108  void setRows(const XYZ& Row1, const XYZ& Row2, const XYZ& Row3);
109 
115  void setScale(const double S);
118  void setValue(const int Row, const int Col, const double Value);
121  XYZ column(const int Col) const;
123  double determinant() const;
125  XYZ diagonal() const;
128  XYZ row(const int Row) const;
131  const double& value(const int Row, const int Col) const;
132 
133  const double& operator()(const int Row, const int Col) const { return value(Row, Col); }
134 
137  double& changeValue(const int Row, const int Col);
138 
139  double& operator()(const int Row, const int Col) { return changeValue(Row, Col); }
140 
144  bool isSingular() const;
145 
146  void add(const Mat& Other);
147 
148  void operator+=(const Mat& Other) { add(Other); }
149 
153  Mat added(const Mat& Other) const;
154 
155  Mat operator+(const Mat& Other) const { return added(Other); }
156 
157  void divide(const double Scalar);
158 
159  void operator/=(const double Scalar) { divide(Scalar); }
160 
162  Mat divided(const double Scalar) const;
163 
164  Mat operator/(const double Scalar) const { return divided(Scalar); }
165 
166  void invert();
167 
178  Mat inverted() const;
179 
181  Mat multiplied(const Mat& Other) const;
182 
183  Mat operator*(const Mat& Other) const { return multiplied(Other); }
184 
186  void multiply(const Mat& Other);
187 
188  void operator*=(const Mat& Other) { multiply(Other); }
189 
190  void preMultiply(const Mat& Other);
191 
192  Mat multiplied(const double Scalar) const;
193 
194  Mat operator*(const double Scalar) const { return multiplied(Scalar); }
195 
197  void multiply(const double Scalar);
198 
199  void operator*=(const double Scalar) { multiply(Scalar); }
200 
201  void power(const int N);
202 
208  Mat powered(const int N) const;
209 
210  void subtract(const Mat& Other);
211 
212  void operator-=(const Mat& Other) { subtract(Other); }
213 
216  Mat subtracted(const Mat& Other) const;
217 
218  Mat operator-(const Mat& Other) const { return subtracted(Other); }
219 
220  bool operator==(const Mat& Other) const;
221 
222  bool operator!=(const Mat& Other) const { return !(operator==(Other)); }
223 
224  void transpose();
225 
227  Mat transposed() const;
228 
229  friend class XYZ;
230  friend class CA_Transfrom;
231  friend class gp_GTrsf;
232  friend class Geom::GTrsf;
233 
235 
236  void initFromQuaternion(double w, double x, double y, double z);
237 
238  bool toQuaternion(double& w, double& x, double& y, double& z);
239 
241  // //
242  // ---------------------- END API ---------------------- //
243  // //
245 
246  bool isEqual(const Mat& Other, double Tolerance) const;
247 
248 private:
249  double matrix[3][3];
250 };
251 } // namespace Geom
Geom::Mat::isSingular
bool isSingular() const
Geom::Mat::multiply
void multiply(const Mat &Other)
Computes the product of two matrices <me> = <Other> * <me>.
Geom::Mat::diagonal
XYZ diagonal() const
Returns the main diagonal of the matrix.
Geom::Mat::transpose
void transpose()
Geom::Mat::subtracted
Mat subtracted(const Mat &Other) const
Geom::Mat::multiplied
Mat multiplied(const Mat &Other) const
Computes the product of two matrices <me> * <Other>
Geom::Mat::operator()
const double & operator()(const int Row, const int Col) const
Definition: Mat.h:133
Geom::Mat::Mat
Mat(const double a11, const double a12, const double a13, const double a21, const double a22, const double a23, const double a31, const double a32, const double a33)
Geom::Mat::divided
Mat divided(const double Scalar) const
Divides all the coefficients of the matrix by Scalar
Geom::Mat::toQuaternion
bool toQuaternion(double &w, double &x, double &y, double &z)
Geom::Mat::determinant
double determinant() const
Computes the determinant of the matrix.
Geom::Mat::column
XYZ column(const int Col) const
Geom::Mat::operator*
Mat operator*(const double Scalar) const
Definition: Mat.h:194
Geom::Mat::operator()
double & operator()(const int Row, const int Col)
Definition: Mat.h:139
Geom::Mat::powered
Mat powered(const int N) const
Geom::Mat::setDiagonal
void setDiagonal(const double X1, const double X2, const double X3)
Geom::Mat::setValue
void setValue(const int Row, const int Col, const double Value)
Geom::Mat::setCols
void setCols(const XYZ &Col1, const XYZ &Col2, const XYZ &Col3)
Geom::Mat::changeValue
double & changeValue(const int Row, const int Col)
Geom::XYZ
Definition: XYZ.h:44
Geom::Mat::divide
void divide(const double Scalar)
Geom::Mat::operator!=
bool operator!=(const Mat &Other) const
Definition: Mat.h:222
Geom::Mat::setCross
void setCross(const XYZ &Ref)
Geom::Mat::operator/=
void operator/=(const double Scalar)
Definition: Mat.h:159
Geom::GTrsf
Definition: GTrsf.h:49
Geom::Mat::subtract
void subtract(const Mat &Other)
Geom::Mat::setIdentity
void setIdentity()
Modifies this matrix so that it represents the Identity matrix.
Geom::Mat::invert
void invert()
Geom::Mat::inverted
Mat inverted() const
Geom::Mat::setScale
void setScale(const double S)
Geom::Mat::computeEulerAngles
Geom::XYZ computeEulerAngles() const
Geom::Mat::operator+
Mat operator+(const Mat &Other) const
Definition: Mat.h:155
Geom::Mat::setRows
void setRows(const XYZ &Row1, const XYZ &Row2, const XYZ &Row3)
Geom::Mat::operator*=
void operator*=(const Mat &Other)
Definition: Mat.h:188
Geom::Mat::multiplied
Mat multiplied(const double Scalar) const
Geom::Mat::preMultiply
void preMultiply(const Mat &Other)
Geom::Mat::power
void power(const int N)
Geom::Mat::initFromQuaternion
void initFromQuaternion(double w, double x, double y, double z)
Geom::Mat::operator/
Mat operator/(const double Scalar) const
Definition: Mat.h:164
Geom::Mat::add
void add(const Mat &Other)
Geom::Mat::transposed
Mat transposed() const
Transposes the matrix. A(j, i) -> A (i, j)
Geom::Mat::operator*=
void operator*=(const double Scalar)
Definition: Mat.h:199
Geom::Mat::row
XYZ row(const int Row) const
Geom::Mat::operator==
bool operator==(const Mat &Other) const
Geom::Mat::multiply
void multiply(const double Scalar)
Multiplies all the coefficients of the matrix by Scalar
Geom::Mat::isEqual
bool isEqual(const Mat &Other, double Tolerance) const
Geom::Mat::setDot
void setDot(const XYZ &Ref)
Geom::Mat::isIdentity
bool isIdentity() const
Returns true if this matrix represents the Identity matrix.
Geom::Mat::Mat
Mat()
creates a matrix with null coefficients.
Geom::Mat::operator*
Mat operator*(const Mat &Other) const
Definition: Mat.h:183
Geom::Mat::added
Mat added(const Mat &Other) const
Geom::Mat::setRotation
void setRotation(const XYZ &Axis, const double Ang)
Geom::Mat::value
const double & value(const int Row, const int Col) const
Geom::Mat::Mat
Mat(const XYZ &Col1, const XYZ &Col2, const XYZ &Col3)
Geom::Mat::setCol
void setCol(const int Col, const XYZ &Value)
Geom::Mat
Definition: Mat.h:37
Geom::Mat::operator-
Mat operator-(const Mat &Other) const
Definition: Mat.h:218
Geom::Mat::setRow
void setRow(const int Row, const XYZ &Value)
Geom::Mat::operator-=
void operator-=(const Mat &Other)
Definition: Mat.h:212
Geom
Definition: PropertyContainer.h:33
Geom::Mat::operator+=
void operator+=(const Mat &Other)
Definition: Mat.h:148