Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Toolbox/LinearAlgebra.h @ 1962:c6272d7bb6d9
display of orientation markers in Stone Web viewer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 27 Oct 2022 19:12:29 +0200 |
parents | 6ce81914f7e4 |
children | 187a261d7ae2 |
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 | |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
158 | 7 * |
8 * 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
|
9 * modify it under the terms of the GNU Lesser General Public License |
158 | 10 * as published by the Free Software Foundation, either version 3 of |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * 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
|
15 * 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
|
16 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
17 * |
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
|
18 * 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
|
19 * 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
|
20 * <http://www.gnu.org/licenses/>. |
158 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
26 // Patch for ublas in Boost 1.64.0 | |
27 // https://github.com/dealii/dealii/issues/4302 | |
28 #include <boost/version.hpp> | |
29 #if BOOST_VERSION >= 106300 // or 64, need to check | |
30 # include <boost/serialization/array_wrapper.hpp> | |
31 #endif | |
32 | |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
33 #include <DicomFormat/DicomMap.h> |
158 | 34 |
35 #include <boost/numeric/ublas/matrix.hpp> | |
36 #include <boost/numeric/ublas/vector.hpp> | |
37 | |
38 namespace OrthancStone | |
39 { | |
40 typedef boost::numeric::ublas::matrix<double> Matrix; | |
41 typedef boost::numeric::ublas::vector<double> Vector; | |
42 | |
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
|
43 // 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
|
44 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
|
45 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
|
46 |
158 | 47 namespace LinearAlgebra |
48 { | |
49 void Print(const Vector& v); | |
50 | |
51 void Print(const Matrix& m); | |
52 | |
53 bool ParseVector(Vector& target, | |
54 const std::string& s); | |
55 | |
56 bool ParseVector(Vector& target, | |
57 const Orthanc::DicomMap& dataset, | |
58 const Orthanc::DicomTag& tag); | |
59 | |
181 | 60 inline void AssignVector(Vector& v, |
61 double v1, | |
62 double v2) | |
63 { | |
64 v.resize(2); | |
65 v[0] = v1; | |
66 v[1] = v2; | |
67 } | |
68 | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
69 |
181 | 70 inline void AssignVector(Vector& v, |
71 double v1) | |
72 { | |
73 v.resize(1); | |
74 v[0] = v1; | |
75 } | |
76 | |
158 | 77 |
181 | 78 inline void AssignVector(Vector& v, |
79 double v1, | |
80 double v2, | |
81 double v3) | |
82 { | |
83 v.resize(3); | |
84 v[0] = v1; | |
85 v[1] = v2; | |
86 v[2] = v3; | |
87 } | |
88 | |
158 | 89 |
181 | 90 inline void AssignVector(Vector& v, |
91 double v1, | |
92 double v2, | |
93 double v3, | |
94 double v4) | |
95 { | |
96 v.resize(4); | |
97 v[0] = v1; | |
98 v[1] = v2; | |
99 v[2] = v3; | |
100 v[3] = v4; | |
101 } | |
161
197a5ddaf68c
FiniteProjectiveCamera
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
159
diff
changeset
|
102 |
181 | 103 |
104 inline Vector CreateVector(double v1) | |
105 { | |
106 Vector v; | |
107 AssignVector(v, v1); | |
108 return v; | |
109 } | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
110 |
181 | 111 |
112 inline Vector CreateVector(double v1, | |
113 double v2) | |
114 { | |
115 Vector v; | |
116 AssignVector(v, v1, v2); | |
117 return v; | |
118 } | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
119 |
181 | 120 |
121 inline Vector CreateVector(double v1, | |
122 double v2, | |
123 double v3) | |
124 { | |
125 Vector v; | |
126 AssignVector(v, v1, v2, v3); | |
127 return v; | |
128 } | |
129 | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
130 |
181 | 131 inline Vector CreateVector(double v1, |
132 double v2, | |
133 double v3, | |
134 double v4) | |
135 { | |
136 Vector v; | |
137 AssignVector(v, v1, v2, v3, v4); | |
138 return v; | |
139 } | |
140 | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
141 |
158 | 142 inline bool IsNear(double x, |
143 double y, | |
144 double threshold) | |
145 { | |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
146 return fabs(x - y) <= threshold; |
158 | 147 } |
148 | |
181 | 149 inline bool IsNear(double x, |
150 double y) | |
151 { | |
152 // As most input is read as single-precision numbers, we take the | |
153 // epsilon machine for float32 into consideration to compare numbers | |
154 return IsNear(x, y, 10.0 * std::numeric_limits<float>::epsilon()); | |
155 } | |
158 | 156 |
157 inline bool IsCloseToZero(double x) | |
158 { | |
159 return IsNear(x, 0.0); | |
160 } | |
161 | |
162 void NormalizeVector(Vector& u); | |
163 | |
164 void CrossProduct(Vector& result, | |
165 const Vector& u, | |
166 const Vector& v); | |
1002 | 167 |
168 double DotProduct(const Vector& u, const Vector& v); | |
169 | |
158 | 170 void FillMatrix(Matrix& target, |
171 size_t rows, | |
172 size_t columns, | |
173 const double values[]); | |
174 | |
175 void FillVector(Vector& target, | |
176 size_t size, | |
177 const double values[]); | |
178 | |
179 void Convert(Matrix& target, | |
180 const Vector& source); | |
159
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
181 |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
182 inline Matrix Transpose(const Matrix& 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 return boost::numeric::ublas::trans(a); |
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 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
188 inline Matrix IdentityMatrix(size_t 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 return boost::numeric::ublas::identity_matrix<double>(size); |
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 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
194 inline Matrix ZeroMatrix(size_t size1, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
195 size_t 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 return boost::numeric::ublas::zero_matrix<double>(size1, size2); |
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 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
201 inline Matrix Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
202 const Matrix& 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 return boost::numeric::ublas::prod(a, b); |
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 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
208 inline Vector Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
209 const Vector& 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 return boost::numeric::ublas::prod(a, b); |
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 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
215 inline Matrix Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
216 const Matrix& b, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
217 const Matrix& 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 return Product(a, Product(b, c)); |
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 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
223 inline Matrix Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
224 const Matrix& b, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
225 const Matrix& c, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
226 const Matrix& 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 return Product(a, Product(b, c, d)); |
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 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
232 inline Matrix Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
233 const Matrix& b, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
234 const Matrix& c, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
235 const Matrix& d, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
236 const Matrix& 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 return Product(a, Product(b, c, d, e)); |
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 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
242 inline Vector Product(const Matrix& a, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
243 const Matrix& b, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
244 const Vector& 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 return Product(Product(a, b), c); |
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 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
249 |
166 | 250 inline Vector Product(const Matrix& a, |
251 const Matrix& b, | |
252 const Matrix& c, | |
253 const Vector& d) | |
254 { | |
255 return Product(Product(a, b, c), d); | |
256 } | |
257 | |
258 | |
159
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
259 double ComputeDeterminant(const Matrix& a); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
260 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
261 bool IsOrthogonalMatrix(const Matrix& q, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
262 double threshold); |
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 IsOrthogonalMatrix(const Matrix& q); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
265 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
266 bool IsRotationMatrix(const Matrix& r, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
267 double threshold); |
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 bool IsRotationMatrix(const Matrix& r); |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
270 |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
271 void InvertUpperTriangularMatrix(Matrix& output, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
272 const Matrix& k); |
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 /** |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
275 * This function computes the RQ decomposition of a 3x3 matrix, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
276 * using Givens rotations. Reference: Algorithm A4.1 (page 579) of |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
277 * "Multiple View Geometry in Computer Vision" (2nd edition). The |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
278 * output matrix "Q" is a rotation matrix, and "R" is upper |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
279 * triangular. |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
280 **/ |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
281 void RQDecomposition3x3(Matrix& r, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
282 Matrix& q, |
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
283 const Matrix& a); |
163
8c5b24892ed2
LinearAlgebra::InvertMatrix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
161
diff
changeset
|
284 |
8c5b24892ed2
LinearAlgebra::InvertMatrix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
161
diff
changeset
|
285 void InvertMatrix(Matrix& target, |
8c5b24892ed2
LinearAlgebra::InvertMatrix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
161
diff
changeset
|
286 const Matrix& source); |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
287 |
169 | 288 // This is the same as "InvertMatrix()", but without exception |
289 bool InvertMatrixUnsafe(Matrix& target, | |
290 const Matrix& source); | |
291 | |
165
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
292 void CreateSkewSymmetric(Matrix& s, |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
293 const Vector& v); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
294 |
166 | 295 Matrix InvertScalingTranslationMatrix(const Matrix& t); |
165
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 bool IsShearMatrix(const Matrix& shear); |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
298 |
8d50e6be565d
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
163
diff
changeset
|
299 Matrix InvertShearMatrix(const Matrix& shear); |
1890
6ce81914f7e4
added classes BucketAccumulator1D/2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
300 |
6ce81914f7e4
added classes BucketAccumulator1D/2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
301 double ComputeMedian(std::vector<double>& v); |
6ce81914f7e4
added classes BucketAccumulator1D/2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
302 |
6ce81914f7e4
added classes BucketAccumulator1D/2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
303 float ComputeMedian(std::vector<float>& v); |
158 | 304 }; |
305 } |