QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
RMatrix.h
Go to the documentation of this file.
1
20#ifndef RMATRIX_H
21#define RMATRIX_H
22
23#include "../core_global.h"
24
25class RVector;
26
27#define RMATRIX_TOLERANCE 1.0e-8
28
37public:
38 RMatrix();
39 RMatrix(int r, int c);
40 RMatrix(const RMatrix& other);
41 ~RMatrix();
42
43 bool isValid() const;
44
45 static RMatrix createIdentity2x2();
46 static RMatrix createIdentity3x3();
47 static RMatrix createIdentity(int size);
48 static RMatrix createRotation(double angle);
49 static RMatrix create2x2(double a11, double a12,
50 double a21, double a22);
51 static RMatrix create3x3(double a11, double a12, double a13,
52 double a21, double a22, double a23,
53 double a31, double a32, double a33);
54 static RMatrix create3x1(double a11, double a21, double a31);
55 static RMatrix create2x3(double a11, double a12, double a13,
56 double a21, double a22, double a23);
57
61 RMatrix& operator =(const RMatrix& other);
65 bool operator ==(const RMatrix& other) const;
66
67 RMatrix operator *(double s) const;
68
72 RMatrix operator *=(double f);
76 RMatrix operator *(const RMatrix& other) const;
77
78 RMatrix multiplyWith(const RMatrix& w) const;
79 RMatrix multiplyWith(double w) const;
80 RVector multiplyWith(const RVector& w) const;
81
85 double* operator [](int i);
86
87 void init(int r, int c);
88 void reset();
89 void clear();
90
91 void set3x3(double a11, double a12, double a13,
92 double a21, double a22, double a23,
93 double a31, double a32, double a33);
94 void set3x1(double a11, double a21, double a31);
95 void set2x3(double a11, double a12,
96 double a13, double a21,
97 double a22, double a23);
98
99 void set(int r, int c, double v);
100 double get(int r, int c) const;
101
105 int getRows() const {
106 return rows;
107 }
111 int getCols() const {
112 return cols;
113 }
114
115 bool rref();
116
117 RMatrix getInverse() const;
118 RMatrix getTransposed() const;
119 RMatrix getAppended(const RMatrix& v) const;
120
121 bool isRotationAndUniformScale() const;
122 double getUniformScaleFactor() const;
123 double getRotationAngle() const;
124
125protected:
126 bool ref(int startRow);
127 void multiplyRow(int r, double factor);
128 void addRow(int r, double factor, int r2);
129 void swapRows(int r1, int r2);
130 int getPivotRow(int startRow);
131 int getPivotCol(int r);
132
133private:
134 double** m;
135 int rows, cols;
136};
137
138RMatrix operator *(double factor, const RMatrix& matrix);
139
140QCADCORE_EXPORT QDebug operator<<(QDebug dbg, const RMatrix& m);
141
144
145#endif
void init(void basePath)
Definition AddBlockInit.js:2
Q_DECLARE_METATYPE(RMath *)
RMatrix operator*(double factor, const RMatrix &matrix)
Definition RMatrix.cpp:691
QCADCORE_EXPORT QDebug operator<<(QDebug dbg, const RMatrix &m)
Stream operator for QDebug.
Definition RMatrix.cpp:698
int i
Copyright (c) 2011-2018 by Andrew Mustun.
Definition autostart.js:32
Simple matrix class.
Definition RMatrix.h:36
int getRows() const
Definition RMatrix.h:105
double ** m
Definition RMatrix.h:134
int cols
Definition RMatrix.h:135
int getCols() const
Definition RMatrix.h:111
Represents a 3d vector (x/y/z).
Definition RVector.h:47
#define QCADCORE_EXPORT
Definition core_global.h:10
ON_DECL ON_2fPoint operator*(int, const ON_2fPoint &)
Definition opennurbs_point.cpp:1718
char s
Definition opennurbs_string.cpp:32