Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Toolbox/LinearAlgebra.h @ 1653:2e3b2ed239b9
Fixed usage of object cookie
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 16 Nov 2020 22:17:01 +0100 |
parents | 8563ea5d8ae4 |
children | 9ac2a65d4172 |
rev | line source |
---|---|
158 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1002
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
158 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
158 | 9 * as published by the Free Software Foundation, either version 3 of |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
158 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
25 // Patch for ublas in Boost 1.64.0 | |
26 // https://github.com/dealii/dealii/issues/4302 | |
27 #include <boost/version.hpp> | |
28 #if BOOST_VERSION >= 106300 // or 64, need to check | |
29 # include <boost/serialization/array_wrapper.hpp> | |
30 #endif | |
31 | |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
32 #include <DicomFormat/DicomMap.h> |
158 | 33 |
34 #include <boost/numeric/ublas/matrix.hpp> | |
35 #include <boost/numeric/ublas/vector.hpp> | |
36 | |
37 namespace OrthancStone | |
38 { | |
39 typedef boost::numeric::ublas::matrix<double> Matrix; | |
40 typedef boost::numeric::ublas::vector<double> Vector; | |
41 | |
949
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
647
diff
changeset
|
42 // logs, debugging... |
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
647
diff
changeset
|
43 std::ostream& operator<<(std::ostream& s, const Vector& vec); |
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
647
diff
changeset
|
44 std::ostream& operator<<(std::ostream& s, const Matrix& m); |
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
647
diff
changeset
|
45 |
158 | 46 namespace LinearAlgebra |
47 { | |
48 void Print(const Vector& v); | |
49 | |
50 void Print(const Matrix& m); | |
51 | |
52 bool ParseVector(Vector& target, | |
53 const std::string& s); | |
54 | |
55 bool ParseVector(Vector& target, | |
56 const Orthanc::DicomMap& dataset, | |
57 const Orthanc::DicomTag& tag); | |
58 | |
181 | 59 inline void AssignVector(Vector& v, |
60 double v1, | |
61 double v2) | |
62 { | |
63 v.resize(2); | |
64 v[0] = v1; | |
65 v[1] = v2; | |
66 } | |
67 | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
68 |
181 | 69 inline void AssignVector(Vector& v, |
70 double v1) | |
71 { | |
72 v.resize(1); | |
73 v[0] = v1; | |
74 } | |
75 | |
158 | 76 |
181 | 77 inline void AssignVector(Vector& v, |
78 double v1, | |
79 double v2, | |
80 double v3) | |
81 { | |
82 v.resize(3); | |
83 v[0] = v1; | |
84 v[1] = v2; | |
85 v[2] = v3; | |
86 } | |
87 | |
158 | 88 |
181 | 89 inline void AssignVector(Vector& v, |
90 double v1, | |
91 double v2, | |
92 double v3, | |
93 double v4) | |
94 { | |
95 v.resize(4); | |
96 v[0] = v1; | |
97 v[1] = v2; | |
98 v[2] = v3; | |
99 v[3] = v4; | |
100 } | |
161
197a5ddaf68c
FiniteProjectiveCamera
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
159
diff
changeset
|
101 |
181 | 102 |
103 inline Vector CreateVector(double v1) | |
104 { | |
105 Vector v; | |
106 AssignVector(v, v1); | |
107 return v; | |
108 } | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
109 |
181 | 110 |
111 inline Vector CreateVector(double v1, | |
112 double v2) | |
113 { | |
114 Vector v; | |
115 AssignVector(v, v1, v2); | |
116 return v; | |
117 } | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
118 |
181 | 119 |
120 inline Vector CreateVector(double v1, | |
121 double v2, | |
122 double v3) | |
123 { | |
124 Vector v; | |
125 AssignVector(v, v1, v2, v3); | |
126 return v; | |
127 } | |
128 | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
129 |
181 | 130 inline Vector CreateVector(double v1, |
131 double v2, | |
132 double v3, | |
133 double v4) | |
134 { | |
135 Vector v; | |
136 AssignVector(v, v1, v2, v3, v4); | |
137 return v; | |
138 } | |
139 | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
140 |
158 | 141 inline bool IsNear(double x, |
142 double y, | |
143 double threshold) | |
144 { | |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
145 return fabs(x - y) <= threshold; |
158 | 146 } |
147 | |
181 | 148 inline bool IsNear(double x, |
149 double y) | |
150 { | |
151 // As most input is read as single-precision numbers, we take the | |
152 // epsilon machine for float32 into consideration to compare numbers | |
153 return IsNear(x, y, 10.0 * std::numeric_limits<float>::epsilon()); | |
154 } | |
158 | 155 |
156 inline bool IsCloseToZero(double x) | |
157 { | |
158 return IsNear(x, 0.0); | |
159 } | |
160 | |
161 void NormalizeVector(Vector& u); | |
162 | |
163 void CrossProduct(Vector& result, | |
164 const Vector& u, | |
165 const Vector& v); | |
1002 | 166 |
167 double DotProduct(const Vector& u, const Vector& v); | |
168 | |
158 | 169 void FillMatrix(Matrix& target, |
170 size_t rows, | |
171 size_t columns, | |
172 const double values[]); | |
173 | |
174 void FillVector(Vector& target, | |
175 size_t size, | |
176 const double values[]); | |
177 | |
178 void Convert(Matrix& target, | |
179 const Vector& source); | |
159
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
180 |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
181 inline Matrix Transpose(const Matrix& a) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
182 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
183 return boost::numeric::ublas::trans(a); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
184 } |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
185 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
186 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
187 inline Matrix IdentityMatrix(size_t size) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
188 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
189 return boost::numeric::ublas::identity_matrix<double>(size); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
190 } |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
191 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
192 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
193 inline Matrix ZeroMatrix(size_t size1, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
194 size_t size2) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
195 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
196 return boost::numeric::ublas::zero_matrix<double>(size1, size2); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
197 } |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
198 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
199 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
200 inline Matrix Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
201 const Matrix& b) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
202 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
203 return boost::numeric::ublas::prod(a, b); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
204 } |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
205 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
206 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
207 inline Vector Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
208 const Vector& b) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
209 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
210 return boost::numeric::ublas::prod(a, b); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
211 } |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
212 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
213 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
214 inline Matrix Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
215 const Matrix& b, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
216 const Matrix& c) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
217 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
218 return Product(a, Product(b, c)); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
219 } |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
220 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
221 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
222 inline Matrix Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
223 const Matrix& b, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
224 const Matrix& c, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
225 const Matrix& d) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
226 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
227 return Product(a, Product(b, c, d)); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
228 } |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
229 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
230 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
231 inline Matrix Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
232 const Matrix& b, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
233 const Matrix& c, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
234 const Matrix& d, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
235 const Matrix& e) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
236 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
237 return Product(a, Product(b, c, d, e)); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
238 } |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
239 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
240 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
241 inline Vector Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
242 const Matrix& b, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
243 const Vector& c) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
244 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
245 return Product(Product(a, b), c); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
246 } |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
247 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
248 |
166 | 249 inline Vector Product(const Matrix& a, |
250 const Matrix& b, | |
251 const Matrix& c, | |
252 const Vector& d) | |
253 { | |
254 return Product(Product(a, b, c), d); | |
255 } | |
256 | |
257 | |
159
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
258 double ComputeDeterminant(const Matrix& a); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
259 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
260 bool IsOrthogonalMatrix(const Matrix& q, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
261 double threshold); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
262 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
263 bool IsOrthogonalMatrix(const Matrix& q); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
264 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
265 bool IsRotationMatrix(const Matrix& r, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
266 double threshold); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
267 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
268 bool IsRotationMatrix(const Matrix& r); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
269 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
270 void InvertUpperTriangularMatrix(Matrix& output, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
271 const Matrix& k); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
272 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
273 /** |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
274 * This function computes the RQ decomposition of a 3x3 matrix, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
275 * using Givens rotations. Reference: Algorithm A4.1 (page 579) of |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
276 * "Multiple View Geometry in Computer Vision" (2nd edition). The |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
277 * output matrix "Q" is a rotation matrix, and "R" is upper |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
278 * triangular. |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
279 **/ |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
280 void RQDecomposition3x3(Matrix& r, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
281 Matrix& q, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
282 const Matrix& a); |
163
8c5b24892ed2
LinearAlgebra::InvertMatrix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
161
diff
changeset
|
283 |
8c5b24892ed2
LinearAlgebra::InvertMatrix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
161
diff
changeset
|
284 void InvertMatrix(Matrix& target, |
8c5b24892ed2
LinearAlgebra::InvertMatrix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
161
diff
changeset
|
285 const Matrix& source); |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
286 |
169 | 287 // This is the same as "InvertMatrix()", but without exception |
288 bool InvertMatrixUnsafe(Matrix& target, | |
289 const Matrix& source); | |
290 | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
291 void CreateSkewSymmetric(Matrix& s, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
292 const Vector& v); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
293 |
166 | 294 Matrix InvertScalingTranslationMatrix(const Matrix& t); |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
295 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
296 bool IsShearMatrix(const Matrix& shear); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
297 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
298 Matrix InvertShearMatrix(const Matrix& shear); |
158 | 299 }; |
300 } |