Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/LinearAlgebra.h @ 1313:f30905f5d246 broker
Added support for OnGenericSdlEvent to GuiAdapter.
This makes it possible to piggyback app-specific logic
to special events (here, to support the Viewport refresh
events)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 16 Mar 2020 11:12:39 +0100 |
parents | 2d8ab34c8c91 |
children | 30deba7bc8e2 |
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 | |
8 * modify it under the terms of the GNU Affero General Public License | |
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 | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 // Patch for ublas in Boost 1.64.0 | |
25 // https://github.com/dealii/dealii/issues/4302 | |
26 #include <boost/version.hpp> | |
27 #if BOOST_VERSION >= 106300 // or 64, need to check | |
28 # include <boost/serialization/array_wrapper.hpp> | |
29 #endif | |
30 | |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
31 #include <Core/DicomFormat/DicomMap.h> |
158 | 32 |
33 #include <boost/numeric/ublas/matrix.hpp> | |
34 #include <boost/numeric/ublas/vector.hpp> | |
35 | |
36 namespace OrthancStone | |
37 { | |
38 typedef boost::numeric::ublas::matrix<double> Matrix; | |
39 typedef boost::numeric::ublas::vector<double> Vector; | |
40 | |
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
|
41 // 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
|
42 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
|
43 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
|
44 |
158 | 45 namespace LinearAlgebra |
46 { | |
47 void Print(const Vector& v); | |
48 | |
49 void Print(const Matrix& m); | |
50 | |
51 bool ParseVector(Vector& target, | |
52 const std::string& s); | |
53 | |
54 bool ParseVector(Vector& target, | |
55 const Orthanc::DicomMap& dataset, | |
56 const Orthanc::DicomTag& tag); | |
57 | |
181 | 58 inline void AssignVector(Vector& v, |
59 double v1, | |
60 double v2) | |
61 { | |
62 v.resize(2); | |
63 v[0] = v1; | |
64 v[1] = v2; | |
65 } | |
66 | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
67 |
181 | 68 inline void AssignVector(Vector& v, |
69 double v1) | |
70 { | |
71 v.resize(1); | |
72 v[0] = v1; | |
73 } | |
74 | |
158 | 75 |
181 | 76 inline void AssignVector(Vector& v, |
77 double v1, | |
78 double v2, | |
79 double v3) | |
80 { | |
81 v.resize(3); | |
82 v[0] = v1; | |
83 v[1] = v2; | |
84 v[2] = v3; | |
85 } | |
86 | |
158 | 87 |
181 | 88 inline void AssignVector(Vector& v, |
89 double v1, | |
90 double v2, | |
91 double v3, | |
92 double v4) | |
93 { | |
94 v.resize(4); | |
95 v[0] = v1; | |
96 v[1] = v2; | |
97 v[2] = v3; | |
98 v[3] = v4; | |
99 } | |
161
197a5ddaf68c
FiniteProjectiveCamera
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
159
diff
changeset
|
100 |
181 | 101 |
102 inline Vector CreateVector(double v1) | |
103 { | |
104 Vector v; | |
105 AssignVector(v, v1); | |
106 return v; | |
107 } | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
108 |
181 | 109 |
110 inline Vector CreateVector(double v1, | |
111 double v2) | |
112 { | |
113 Vector v; | |
114 AssignVector(v, v1, v2); | |
115 return v; | |
116 } | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
117 |
181 | 118 |
119 inline Vector CreateVector(double v1, | |
120 double v2, | |
121 double v3) | |
122 { | |
123 Vector v; | |
124 AssignVector(v, v1, v2, v3); | |
125 return v; | |
126 } | |
127 | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
128 |
181 | 129 inline Vector CreateVector(double v1, |
130 double v2, | |
131 double v3, | |
132 double v4) | |
133 { | |
134 Vector v; | |
135 AssignVector(v, v1, v2, v3, v4); | |
136 return v; | |
137 } | |
138 | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
139 |
158 | 140 inline bool IsNear(double x, |
141 double y, | |
142 double threshold) | |
143 { | |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
144 return fabs(x - y) <= threshold; |
158 | 145 } |
146 | |
181 | 147 inline bool IsNear(double x, |
148 double y) | |
149 { | |
150 // As most input is read as single-precision numbers, we take the | |
151 // epsilon machine for float32 into consideration to compare numbers | |
152 return IsNear(x, y, 10.0 * std::numeric_limits<float>::epsilon()); | |
153 } | |
158 | 154 |
155 inline bool IsCloseToZero(double x) | |
156 { | |
157 return IsNear(x, 0.0); | |
158 } | |
159 | |
160 void NormalizeVector(Vector& u); | |
161 | |
162 void CrossProduct(Vector& result, | |
163 const Vector& u, | |
164 const Vector& v); | |
1002 | 165 |
166 double DotProduct(const Vector& u, const Vector& v); | |
167 | |
158 | 168 void FillMatrix(Matrix& target, |
169 size_t rows, | |
170 size_t columns, | |
171 const double values[]); | |
172 | |
173 void FillVector(Vector& target, | |
174 size_t size, | |
175 const double values[]); | |
176 | |
177 void Convert(Matrix& target, | |
178 const Vector& source); | |
159
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
179 |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
180 inline Matrix Transpose(const Matrix& a) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
181 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
182 return boost::numeric::ublas::trans(a); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
183 } |
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 inline Matrix IdentityMatrix(size_t size) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
187 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
188 return boost::numeric::ublas::identity_matrix<double>(size); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
189 } |
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 inline Matrix ZeroMatrix(size_t size1, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
193 size_t size2) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
194 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
195 return boost::numeric::ublas::zero_matrix<double>(size1, size2); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
196 } |
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 inline Matrix Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
200 const Matrix& b) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
201 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
202 return boost::numeric::ublas::prod(a, b); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
203 } |
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 inline Vector Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
207 const Vector& b) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
208 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
209 return boost::numeric::ublas::prod(a, b); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
210 } |
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 inline Matrix Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
214 const Matrix& b, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
215 const Matrix& c) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
216 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
217 return Product(a, Product(b, c)); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
218 } |
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 inline Matrix Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
222 const Matrix& b, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
223 const Matrix& c, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
224 const Matrix& d) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
225 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
226 return Product(a, Product(b, c, d)); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
227 } |
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 inline Matrix Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
231 const Matrix& b, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
232 const Matrix& c, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
233 const Matrix& d, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
234 const Matrix& e) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
235 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
236 return Product(a, Product(b, c, d, e)); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
237 } |
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 inline Vector Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
241 const Matrix& b, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
242 const Vector& c) |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
243 { |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
244 return Product(Product(a, b), c); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
245 } |
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 |
166 | 248 inline Vector Product(const Matrix& a, |
249 const Matrix& b, | |
250 const Matrix& c, | |
251 const Vector& d) | |
252 { | |
253 return Product(Product(a, b, c), d); | |
254 } | |
255 | |
256 | |
159
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
257 double ComputeDeterminant(const Matrix& a); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
258 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
259 bool IsOrthogonalMatrix(const Matrix& q, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
260 double threshold); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
261 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
262 bool IsOrthogonalMatrix(const Matrix& q); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
263 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
264 bool IsRotationMatrix(const Matrix& r, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
265 double threshold); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
266 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
267 bool IsRotationMatrix(const Matrix& r); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
268 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
269 void InvertUpperTriangularMatrix(Matrix& output, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
270 const Matrix& k); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
271 |
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 * This function computes the RQ decomposition of a 3x3 matrix, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
274 * using Givens rotations. Reference: Algorithm A4.1 (page 579) of |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
275 * "Multiple View Geometry in Computer Vision" (2nd edition). The |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
276 * output matrix "Q" is a rotation matrix, and "R" is upper |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
277 * triangular. |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
278 **/ |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
279 void RQDecomposition3x3(Matrix& r, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
280 Matrix& q, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
281 const Matrix& a); |
163
8c5b24892ed2
LinearAlgebra::InvertMatrix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
161
diff
changeset
|
282 |
8c5b24892ed2
LinearAlgebra::InvertMatrix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
161
diff
changeset
|
283 void InvertMatrix(Matrix& target, |
8c5b24892ed2
LinearAlgebra::InvertMatrix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
161
diff
changeset
|
284 const Matrix& source); |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
285 |
169 | 286 // This is the same as "InvertMatrix()", but without exception |
287 bool InvertMatrixUnsafe(Matrix& target, | |
288 const Matrix& source); | |
289 | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
290 void CreateSkewSymmetric(Matrix& s, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
291 const Vector& v); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
292 |
166 | 293 Matrix InvertScalingTranslationMatrix(const Matrix& t); |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
294 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
295 bool IsShearMatrix(const Matrix& shear); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
296 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
297 Matrix InvertShearMatrix(const Matrix& shear); |
158 | 298 }; |
299 } |