Mercurial > hg > orthanc-stone
annotate OrthancStone/UnitTestsSources/GeometryToolboxTests.cpp @ 2023:e0b7b2a8b914
support generation of ZIP archives in the presence of authorization tokens
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 03 Dec 2022 21:00:36 +0100 |
parents | cbf54cd28d59 |
children | 07964689cb0b |
rev | line source |
---|---|
1679
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
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 |
1679
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
1877
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
1679
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * the License, or (at your option) any later version. |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
1877
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
16 * Lesser General Public License for more details. |
1679
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
1877
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
19 * License along with this program. If not, see |
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
1679
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 **/ |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include <gtest/gtest.h> |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
1877
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
26 #include "../Sources/Toolbox/DicomInstanceParameters.h" |
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
27 #include "../Sources/Toolbox/FiniteProjectiveCamera.h" |
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
28 #include "../Sources/Toolbox/GenericToolbox.h" |
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
29 #include "../Sources/Toolbox/GeometryToolbox.h" |
a2955abe4c2e
skeleton for the RenderingPlugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
30 #include "../Sources/Toolbox/SlicesSorter.h" |
1679
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 #include <Logging.h> |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 #include <OrthancException.h> |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #include <boost/math/special_functions/round.hpp> |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 TEST(GeometryToolbox, Interpolation) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 using namespace OrthancStone::GeometryToolbox; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 // https://en.wikipedia.org/wiki/Bilinear_interpolation#Application_in_image_processing |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 ASSERT_DOUBLE_EQ(146.1f, ComputeBilinearInterpolationUnitSquare(0.5f, 0.2f, 91, 210, 162, 95)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 ASSERT_DOUBLE_EQ(91, ComputeBilinearInterpolationUnitSquare(0, 0, 91, 210, 162, 95)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 ASSERT_DOUBLE_EQ(210, ComputeBilinearInterpolationUnitSquare(1, 0, 91, 210, 162, 95)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 ASSERT_DOUBLE_EQ(162, ComputeBilinearInterpolationUnitSquare(0, 1, 91, 210, 162, 95)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 ASSERT_DOUBLE_EQ(95, ComputeBilinearInterpolationUnitSquare(1, 1, 91, 210, 162, 95)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 ASSERT_DOUBLE_EQ(123.35f, ComputeTrilinearInterpolationUnitSquare |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 (0.5f, 0.2f, 0.7f, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 91, 210, 162, 95, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 51, 190, 80, 92)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 ASSERT_DOUBLE_EQ(ComputeBilinearInterpolationUnitSquare(0.5f, 0.2f, 91, 210, 162, 95), |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 ComputeTrilinearInterpolationUnitSquare(0.5f, 0.2f, 0, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 91, 210, 162, 95, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 51, 190, 80, 92)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 ASSERT_DOUBLE_EQ(ComputeBilinearInterpolationUnitSquare(0.5f, 0.2f, 51, 190, 80, 92), |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 ComputeTrilinearInterpolationUnitSquare(0.5f, 0.2f, 1, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 91, 210, 162, 95, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 51, 190, 80, 92)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 static bool CompareMatrix(const OrthancStone::Matrix& a, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 const OrthancStone::Matrix& b, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 double threshold = 0.00000001) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 if (a.size1() != b.size1() || |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 a.size2() != b.size2()) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 return false; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 for (size_t i = 0; i < a.size1(); i++) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 for (size_t j = 0; j < a.size2(); j++) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 if (fabs(a(i, j) - b(i, j)) > threshold) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 LOG(ERROR) << "Too large difference in component (" |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 << i << "," << j << "): " << a(i,j) << " != " << b(i,j); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 return false; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 return true; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 static bool CompareVector(const OrthancStone::Vector& a, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 const OrthancStone::Vector& b, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 double threshold = 0.00000001) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 if (a.size() != b.size()) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 return false; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 for (size_t i = 0; i < a.size(); i++) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 if (fabs(a(i) - b(i)) > threshold) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 LOG(ERROR) << "Too large difference in component " |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 << i << ": " << a(i) << " != " << b(i); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 return false; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 return true; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 TEST(FiniteProjectiveCamera, Decomposition1) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 // Example 6.2 of "Multiple View Geometry in Computer Vision - 2nd |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 // edition" (page 163) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 const double p[12] = { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 3.53553e+2, 3.39645e+2, 2.77744e+2, -1.44946e+6, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 -1.03528e+2, 2.33212e+1, 4.59607e+2, -6.32525e+5, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 7.07107e-1, -3.53553e-1, 6.12372e-1, -9.18559e+2 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 }; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 OrthancStone::FiniteProjectiveCamera camera(p); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 ASSERT_EQ(3u, camera.GetMatrix().size1()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 ASSERT_EQ(4u, camera.GetMatrix().size2()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 ASSERT_EQ(3u, camera.GetIntrinsicParameters().size1()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 ASSERT_EQ(3u, camera.GetIntrinsicParameters().size2()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 ASSERT_EQ(3u, camera.GetRotation().size1()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 ASSERT_EQ(3u, camera.GetRotation().size2()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 ASSERT_EQ(3u, camera.GetCenter().size()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 ASSERT_NEAR(1000.0, camera.GetCenter()[0], 0.01); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 ASSERT_NEAR(2000.0, camera.GetCenter()[1], 0.01); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 ASSERT_NEAR(1500.0, camera.GetCenter()[2], 0.01); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 ASSERT_NEAR(468.2, camera.GetIntrinsicParameters() (0, 0), 0.1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 ASSERT_NEAR(91.2, camera.GetIntrinsicParameters() (0, 1), 0.1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 ASSERT_NEAR(300.0, camera.GetIntrinsicParameters() (0, 2), 0.1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 ASSERT_NEAR(427.2, camera.GetIntrinsicParameters() (1, 1), 0.1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 ASSERT_NEAR(200.0, camera.GetIntrinsicParameters() (1, 2), 0.1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 ASSERT_NEAR(1.0, camera.GetIntrinsicParameters() (2, 2), 0.1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 ASSERT_NEAR(0, camera.GetIntrinsicParameters() (1, 0), 0.0000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 ASSERT_NEAR(0, camera.GetIntrinsicParameters() (2, 0), 0.0000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 ASSERT_NEAR(0, camera.GetIntrinsicParameters() (2, 1), 0.0000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 ASSERT_NEAR(0.41380, camera.GetRotation() (0, 0), 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 ASSERT_NEAR(0.90915, camera.GetRotation() (0, 1), 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 ASSERT_NEAR(0.04708, camera.GetRotation() (0, 2), 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 ASSERT_NEAR(-0.57338, camera.GetRotation() (1, 0), 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 ASSERT_NEAR(0.22011, camera.GetRotation() (1, 1), 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 ASSERT_NEAR(0.78917, camera.GetRotation() (1, 2), 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 ASSERT_NEAR(0.70711, camera.GetRotation() (2, 0), 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 ASSERT_NEAR(-0.35355, camera.GetRotation() (2, 1), 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 ASSERT_NEAR(0.61237, camera.GetRotation() (2, 2), 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 ASSERT_TRUE(OrthancStone::LinearAlgebra::IsRotationMatrix(camera.GetRotation())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 OrthancStone::FiniteProjectiveCamera camera2(camera.GetIntrinsicParameters(), |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 camera.GetRotation(), |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 camera.GetCenter()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 ASSERT_TRUE(CompareMatrix(camera.GetMatrix(), camera2.GetMatrix())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 ASSERT_TRUE(CompareMatrix(camera.GetIntrinsicParameters(), camera2.GetIntrinsicParameters())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 ASSERT_TRUE(CompareMatrix(camera.GetRotation(), camera2.GetRotation())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 ASSERT_TRUE(CompareVector(camera.GetCenter(), camera2.GetCenter())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 TEST(FiniteProjectiveCamera, Decomposition2) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 const double p[] = { 1188.111986, 580.205341, -808.445330, 128000.000000, -366.466264, 1446.510501, 418.499736, 128000.000000, -0.487118, 0.291726, -0.823172, 500.000000 }; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 const double k[] = { -1528.494743, 0.000000, 256.000000, 0.000000, 1528.494743, 256.000000, 0.000000, 0.000000, 1.000000 }; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 const double r[] = { -0.858893, -0.330733, 0.391047, -0.158171, 0.897503, 0.411668, -0.487118, 0.291726, -0.823172 }; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 const double c[] = { 243.558936, -145.863085, 411.585964 }; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 OrthancStone::FiniteProjectiveCamera camera(p); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 ASSERT_TRUE(OrthancStone::LinearAlgebra::IsRotationMatrix(camera.GetRotation())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 OrthancStone::FiniteProjectiveCamera camera2(k, r, c); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 ASSERT_TRUE(CompareMatrix(camera.GetMatrix(), camera2.GetMatrix(), 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 ASSERT_TRUE(CompareMatrix(camera.GetIntrinsicParameters(), camera2.GetIntrinsicParameters(), 0.001)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 ASSERT_TRUE(CompareMatrix(camera.GetRotation(), camera2.GetRotation(), 0.000001)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 ASSERT_TRUE(CompareVector(camera.GetCenter(), camera2.GetCenter(), 0.0001)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 TEST(FiniteProjectiveCamera, Decomposition3) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 const double p[] = { 10, 0, 0, 0, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 0, 20, 0, 0, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 0, 0, 30, 0 }; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 OrthancStone::FiniteProjectiveCamera camera(p); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 ASSERT_TRUE(OrthancStone::LinearAlgebra::IsRotationMatrix(camera.GetRotation())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 ASSERT_DOUBLE_EQ(10, camera.GetIntrinsicParameters() (0, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 ASSERT_DOUBLE_EQ(20, camera.GetIntrinsicParameters() (1, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 ASSERT_DOUBLE_EQ(30, camera.GetIntrinsicParameters() (2, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 ASSERT_DOUBLE_EQ(1, camera.GetRotation() (0, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 ASSERT_DOUBLE_EQ(1, camera.GetRotation() (1, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 ASSERT_DOUBLE_EQ(1, camera.GetRotation() (2, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 ASSERT_DOUBLE_EQ(0, camera.GetCenter() (0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 ASSERT_DOUBLE_EQ(0, camera.GetCenter() (1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 ASSERT_DOUBLE_EQ(0, camera.GetCenter() (2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 TEST(FiniteProjectiveCamera, Decomposition4) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 const double p[] = { 1, 0, 0, 10, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 0, 1, 0, 20, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 0, 0, 1, 30 }; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 OrthancStone::FiniteProjectiveCamera camera(p); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 ASSERT_TRUE(OrthancStone::LinearAlgebra::IsRotationMatrix(camera.GetRotation())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 ASSERT_DOUBLE_EQ(1, camera.GetIntrinsicParameters() (0, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 ASSERT_DOUBLE_EQ(1, camera.GetIntrinsicParameters() (1, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 ASSERT_DOUBLE_EQ(1, camera.GetIntrinsicParameters() (2, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 ASSERT_DOUBLE_EQ(1, camera.GetRotation() (0, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 ASSERT_DOUBLE_EQ(1, camera.GetRotation() (1, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 ASSERT_DOUBLE_EQ(1, camera.GetRotation() (2, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 ASSERT_DOUBLE_EQ(-10, camera.GetCenter() (0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 ASSERT_DOUBLE_EQ(-20, camera.GetCenter() (1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 ASSERT_DOUBLE_EQ(-30, camera.GetCenter() (2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 TEST(FiniteProjectiveCamera, Decomposition5) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 const double p[] = { 0, 0, 10, 0, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 0, 20, 0, 0, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 30, 0, 0, 0 }; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 OrthancStone::FiniteProjectiveCamera camera(p); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 ASSERT_TRUE(OrthancStone::LinearAlgebra::IsRotationMatrix(camera.GetRotation())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 ASSERT_DOUBLE_EQ(-10, camera.GetIntrinsicParameters() (0, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 ASSERT_DOUBLE_EQ(20, camera.GetIntrinsicParameters() (1, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 ASSERT_DOUBLE_EQ(30, camera.GetIntrinsicParameters() (2, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 ASSERT_DOUBLE_EQ(-1, camera.GetRotation() (0, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 ASSERT_DOUBLE_EQ(1, camera.GetRotation() (1, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 ASSERT_DOUBLE_EQ(1, camera.GetRotation() (2, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 ASSERT_DOUBLE_EQ(0, camera.GetCenter() (0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 ASSERT_DOUBLE_EQ(0, camera.GetCenter() (1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 ASSERT_DOUBLE_EQ(0, camera.GetCenter() (2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 OrthancStone::FiniteProjectiveCamera camera2(camera.GetIntrinsicParameters(), |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 camera.GetRotation(), |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 camera.GetCenter()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 ASSERT_TRUE(CompareMatrix(camera.GetMatrix(), camera2.GetMatrix())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 ASSERT_TRUE(CompareMatrix(camera.GetIntrinsicParameters(), camera2.GetIntrinsicParameters())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 ASSERT_TRUE(CompareMatrix(camera.GetRotation(), camera2.GetRotation())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 ASSERT_TRUE(CompareVector(camera.GetCenter(), camera2.GetCenter())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 static double GetCosAngle(const OrthancStone::Vector& a, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 const OrthancStone::Vector& b) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 // Returns the cosine of the angle between two vectors |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 // https://en.wikipedia.org/wiki/Dot_product#Geometric_definition |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 return boost::numeric::ublas::inner_prod(a, b) / |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 (boost::numeric::ublas::norm_2(a) * boost::numeric::ublas::norm_2(b)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 TEST(FiniteProjectiveCamera, Ray) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 const double pp[] = { -1499.650894, 2954.618773, -259.737419, 637891.819097, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 -2951.517707, -1501.019129, -285.785281, 637891.819097, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 0.008528, 0.003067, -0.999959, 2491.764918 }; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 const OrthancStone::FiniteProjectiveCamera camera(pp); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 ASSERT_NEAR(-21.2492, camera.GetCenter() (0), 0.0001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 ASSERT_NEAR(-7.64234, camera.GetCenter() (1), 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
281 ASSERT_NEAR(2491.66, camera.GetCenter() (2), 0.01); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
282 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
283 // Image plane that led to these parameters, with principal point at |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 // (256,256). The image has dimensions 512x512. |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
285 OrthancStone::Vector o = |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
286 OrthancStone::LinearAlgebra::CreateVector(7.009620, 2.521030, -821.942000); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
287 OrthancStone::Vector ax = |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
288 OrthancStone::LinearAlgebra::CreateVector(-0.453219, 0.891399, -0.001131); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
289 OrthancStone::Vector ay = |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
290 OrthancStone::LinearAlgebra::CreateVector(-0.891359, -0.453210, -0.008992); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
291 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 OrthancStone::CoordinateSystem3D imagePlane(o, ax, ay); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 // Back-projection of the principal point |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
295 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
296 OrthancStone::Vector ray = camera.GetRayDirection(256, 256); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
297 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 // The principal axis vector is orthogonal to the image plane |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 // (i.e. parallel to the plane normal), in the opposite direction |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 // ("-1" corresponds to "cos(pi)"). |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 ASSERT_NEAR(-1, GetCosAngle(ray, imagePlane.GetNormal()), 0.0000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 // Forward projection of principal axis, resulting in the principal point |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 double x, y; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 camera.ApplyFinite(x, y, camera.GetCenter() - ray); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 ASSERT_NEAR(256, x, 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 ASSERT_NEAR(256, y, 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
311 // Back-projection of the 4 corners of the image |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
312 std::vector<double> cx, cy; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
313 cx.push_back(0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
314 cy.push_back(0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
315 cx.push_back(512); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 cy.push_back(0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
317 cx.push_back(512); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 cy.push_back(512); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 cx.push_back(0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 cy.push_back(512); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
321 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
322 bool first = true; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 double angle; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
325 for (size_t i = 0; i < cx.size(); i++) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
327 OrthancStone::Vector ray = camera.GetRayDirection(cx[i], cy[i]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
328 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
329 // Check that the angle wrt. principal axis is the same for all |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 // the 4 corners |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 double a = GetCosAngle(ray, imagePlane.GetNormal()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 if (first) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 first = false; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 angle = a; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 else |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
338 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 ASSERT_NEAR(angle, a, 0.000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
340 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 // Forward projection of the ray, going back to the original point |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
343 double x, y; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 camera.ApplyFinite(x, y, camera.GetCenter() - ray); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
346 ASSERT_NEAR(cx[i], x, 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
347 ASSERT_NEAR(cy[i], y, 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
348 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
349 // Alternative construction, by computing the intersection of the |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 // ray with the image plane |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 OrthancStone::Vector p; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
352 ASSERT_TRUE(imagePlane.IntersectLine(p, camera.GetCenter(), -ray)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
353 imagePlane.ProjectPoint(x, y, p); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
354 ASSERT_NEAR(cx[i], x + 256, 0.01); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
355 ASSERT_NEAR(cy[i], y + 256, 0.01); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
356 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
357 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
358 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
359 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
360 TEST(Matrix, Inverse1) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
361 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 OrthancStone::Matrix a, b; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 a.resize(0, 0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 OrthancStone::LinearAlgebra::InvertMatrix(b, a); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 ASSERT_EQ(0u, b.size1()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 ASSERT_EQ(0u, b.size2()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
369 a.resize(2, 3); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 ASSERT_THROW(OrthancStone::LinearAlgebra::InvertMatrix(b, a), Orthanc::OrthancException); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
371 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
372 a.resize(1, 1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
373 a(0, 0) = 45.0; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 ASSERT_DOUBLE_EQ(45, OrthancStone::LinearAlgebra::ComputeDeterminant(a)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 OrthancStone::LinearAlgebra::InvertMatrix(b, a); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 ASSERT_EQ(1u, b.size1()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 ASSERT_EQ(1u, b.size2()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
379 ASSERT_DOUBLE_EQ(1.0 / 45.0, b(0, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 a(0, 0) = 0; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
382 ASSERT_DOUBLE_EQ(0, OrthancStone::LinearAlgebra::ComputeDeterminant(a)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 ASSERT_THROW(OrthancStone::LinearAlgebra::InvertMatrix(b, a), Orthanc::OrthancException); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 TEST(Matrix, Inverse2) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
388 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
389 OrthancStone::Matrix a, b; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
390 a.resize(2, 2); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 a(0, 0) = 4; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
392 a(0, 1) = 3; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 a(1, 0) = 3; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 a(1, 1) = 2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
396 ASSERT_DOUBLE_EQ(-1, OrthancStone::LinearAlgebra::ComputeDeterminant(a)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 OrthancStone::LinearAlgebra::InvertMatrix(b, a); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
398 ASSERT_EQ(2u, b.size1()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
399 ASSERT_EQ(2u, b.size2()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 ASSERT_DOUBLE_EQ(-2, b(0, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 ASSERT_DOUBLE_EQ(3, b(0, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 ASSERT_DOUBLE_EQ(3, b(1, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 ASSERT_DOUBLE_EQ(-4, b(1, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 a(0, 0) = 1; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 a(0, 1) = 2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 a(1, 0) = 3; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
409 a(1, 1) = 4; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
410 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
411 ASSERT_DOUBLE_EQ(-2, OrthancStone::LinearAlgebra::ComputeDeterminant(a)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
412 OrthancStone::LinearAlgebra::InvertMatrix(b, a); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
413 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
414 ASSERT_DOUBLE_EQ(-2, b(0, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
415 ASSERT_DOUBLE_EQ(1, b(0, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
416 ASSERT_DOUBLE_EQ(1.5, b(1, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 ASSERT_DOUBLE_EQ(-0.5, b(1, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
418 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
419 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
420 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
421 TEST(Matrix, Inverse3) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
422 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 OrthancStone::Matrix a, b; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
424 a.resize(3, 3); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 a(0, 0) = 7; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 a(0, 1) = 2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
427 a(0, 2) = 1; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
428 a(1, 0) = 0; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
429 a(1, 1) = 3; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
430 a(1, 2) = -1; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
431 a(2, 0) = -3; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
432 a(2, 1) = 4; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
433 a(2, 2) = -2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
434 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
435 ASSERT_DOUBLE_EQ(1, OrthancStone::LinearAlgebra::ComputeDeterminant(a)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
436 OrthancStone::LinearAlgebra::InvertMatrix(b, a); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
437 ASSERT_EQ(3u, b.size1()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
438 ASSERT_EQ(3u, b.size2()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
439 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 ASSERT_DOUBLE_EQ(-2, b(0, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
441 ASSERT_DOUBLE_EQ(8, b(0, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
442 ASSERT_DOUBLE_EQ(-5, b(0, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
443 ASSERT_DOUBLE_EQ(3, b(1, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
444 ASSERT_DOUBLE_EQ(-11, b(1, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
445 ASSERT_DOUBLE_EQ(7, b(1, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
446 ASSERT_DOUBLE_EQ(9, b(2, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
447 ASSERT_DOUBLE_EQ(-34, b(2, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
448 ASSERT_DOUBLE_EQ(21, b(2, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
449 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
450 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
451 a(0, 0) = 1; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
452 a(0, 1) = 2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
453 a(0, 2) = 2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
454 a(1, 0) = 1; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
455 a(1, 1) = 0; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
456 a(1, 2) = 1; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
457 a(2, 0) = 1; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
458 a(2, 1) = 2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
459 a(2, 2) = 1; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
460 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
461 ASSERT_DOUBLE_EQ(2, OrthancStone::LinearAlgebra::ComputeDeterminant(a)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
462 OrthancStone::LinearAlgebra::InvertMatrix(b, a); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
463 ASSERT_EQ(3u, b.size1()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
464 ASSERT_EQ(3u, b.size2()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
465 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
466 ASSERT_DOUBLE_EQ(-1, b(0, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
467 ASSERT_DOUBLE_EQ(1, b(0, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
468 ASSERT_DOUBLE_EQ(1, b(0, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
469 ASSERT_DOUBLE_EQ(0, b(1, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
470 ASSERT_DOUBLE_EQ(-0.5, b(1, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
471 ASSERT_DOUBLE_EQ(0.5, b(1, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
472 ASSERT_DOUBLE_EQ(1, b(2, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
473 ASSERT_DOUBLE_EQ(0, b(2, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
474 ASSERT_DOUBLE_EQ(-1, b(2, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
475 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
476 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
477 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
478 TEST(Matrix, Inverse4) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
479 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
480 OrthancStone::Matrix a, b; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 a.resize(4, 4); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
482 a(0, 0) = 2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
483 a(0, 1) = 1; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 a(0, 2) = 2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 a(0, 3) = -3; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
486 a(1, 0) = -2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
487 a(1, 1) = 2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
488 a(1, 2) = -1; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
489 a(1, 3) = -1; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
490 a(2, 0) = 2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
491 a(2, 1) = 2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
492 a(2, 2) = -3; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
493 a(2, 3) = -1; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
494 a(3, 0) = 3; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
495 a(3, 1) = -2; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
496 a(3, 2) = -3; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
497 a(3, 3) = -1; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
498 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
499 OrthancStone::LinearAlgebra::InvertMatrix(b, a); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
500 ASSERT_EQ(4u, b.size1()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
501 ASSERT_EQ(4u, b.size2()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
502 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
503 b *= 134.0; // This is the determinant |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
504 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 ASSERT_DOUBLE_EQ(8, b(0, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 ASSERT_DOUBLE_EQ(-44, b(0, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
507 ASSERT_DOUBLE_EQ(30, b(0, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
508 ASSERT_DOUBLE_EQ(-10, b(0, 3)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
509 ASSERT_DOUBLE_EQ(2, b(1, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
510 ASSERT_DOUBLE_EQ(-11, b(1, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
511 ASSERT_DOUBLE_EQ(41, b(1, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
512 ASSERT_DOUBLE_EQ(-36, b(1, 3)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
513 ASSERT_DOUBLE_EQ(16, b(2, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
514 ASSERT_DOUBLE_EQ(-21, b(2, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
515 ASSERT_DOUBLE_EQ(-7, b(2, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
516 ASSERT_DOUBLE_EQ(-20, b(2, 3)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
517 ASSERT_DOUBLE_EQ(-28, b(3, 0)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
518 ASSERT_DOUBLE_EQ(-47, b(3, 1)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
519 ASSERT_DOUBLE_EQ(29, b(3, 2)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
520 ASSERT_DOUBLE_EQ(-32, b(3, 3)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
521 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
522 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
523 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
524 TEST(FiniteProjectiveCamera, Calibration) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
525 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
526 unsigned int volumeWidth = 512; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
527 unsigned int volumeHeight = 512; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
528 unsigned int volumeDepth = 110; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
529 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
530 OrthancStone::Vector camera = OrthancStone::LinearAlgebra::CreateVector |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
531 (-1000, -5000, -static_cast<double>(volumeDepth) * 32); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 OrthancStone::Vector principalPoint = OrthancStone::LinearAlgebra::CreateVector |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 (volumeWidth/2, volumeHeight/2, volumeDepth * 2); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
535 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
536 OrthancStone::FiniteProjectiveCamera c(camera, principalPoint, 0, 512, 512, 1, 1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 double swapv[9] = { 1, 0, 0, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 0, -1, 512, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
540 0, 0, 1 }; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 OrthancStone::Matrix swap; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 OrthancStone::LinearAlgebra::FillMatrix(swap, 3, 3, swapv); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
543 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
544 OrthancStone::Matrix p = OrthancStone::LinearAlgebra::Product(swap, c.GetMatrix()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
545 p /= p(2,3); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
546 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
547 ASSERT_NEAR( 1.04437, p(0,0), 0.00001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
548 ASSERT_NEAR(-0.0703111, p(0,1), 0.00000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
549 ASSERT_NEAR(-0.179283, p(0,2), 0.000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 ASSERT_NEAR( 61.7431, p(0,3), 0.0001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
551 ASSERT_NEAR( 0.11127, p(1,0), 0.000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
552 ASSERT_NEAR(-0.595541, p(1,1), 0.000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
553 ASSERT_NEAR( 0.872211, p(1,2), 0.000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
554 ASSERT_NEAR( 203.748, p(1,3), 0.001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
555 ASSERT_NEAR( 3.08593e-05, p(2,0), 0.0000000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
556 ASSERT_NEAR( 0.000129138, p(2,1), 0.000000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
557 ASSERT_NEAR( 9.18901e-05, p(2,2), 0.0000000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
558 ASSERT_NEAR( 1, p(2,3), 0.0000001); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
559 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
560 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
561 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
562 static bool IsEqualRotationVector(OrthancStone::Vector a, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
563 OrthancStone::Vector b) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
564 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
565 if (a.size() != b.size() || |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
566 a.size() != 3) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
567 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
568 return false; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
569 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
570 else |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
571 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
572 OrthancStone::LinearAlgebra::NormalizeVector(a); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
573 OrthancStone::LinearAlgebra::NormalizeVector(b); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
574 return OrthancStone::LinearAlgebra::IsCloseToZero(boost::numeric::ublas::norm_2(a - b)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
575 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
576 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
577 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
578 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
579 TEST(GeometryToolbox, AlignVectorsWithRotation) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
580 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
581 OrthancStone::Vector a, b; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
582 OrthancStone::Matrix r; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
583 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
584 OrthancStone::LinearAlgebra::AssignVector(a, -200, 200, -846.63); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
585 OrthancStone::LinearAlgebra::AssignVector(b, 0, 0, 1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
586 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
587 OrthancStone::GeometryToolbox::AlignVectorsWithRotation(r, a, b); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
588 ASSERT_TRUE(OrthancStone::LinearAlgebra::IsRotationMatrix(r)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
589 ASSERT_TRUE(IsEqualRotationVector(OrthancStone::LinearAlgebra::Product(r, a), b)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
590 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
591 OrthancStone::GeometryToolbox::AlignVectorsWithRotation(r, b, a); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
592 ASSERT_TRUE(OrthancStone::LinearAlgebra::IsRotationMatrix(r)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
593 ASSERT_TRUE(IsEqualRotationVector(OrthancStone::LinearAlgebra::Product(r, b), a)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
594 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
595 OrthancStone::LinearAlgebra::AssignVector(a, 1, 0, 0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
596 OrthancStone::LinearAlgebra::AssignVector(b, 0, 0, 1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
597 OrthancStone::GeometryToolbox::AlignVectorsWithRotation(r, a, b); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
598 ASSERT_TRUE(OrthancStone::LinearAlgebra::IsRotationMatrix(r)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
599 ASSERT_TRUE(IsEqualRotationVector(OrthancStone::LinearAlgebra::Product(r, a), b)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
600 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
601 OrthancStone::LinearAlgebra::AssignVector(a, 0, 1, 0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
602 OrthancStone::LinearAlgebra::AssignVector(b, 0, 0, 1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
603 OrthancStone::GeometryToolbox::AlignVectorsWithRotation(r, a, b); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
604 ASSERT_TRUE(OrthancStone::LinearAlgebra::IsRotationMatrix(r)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
605 ASSERT_TRUE(IsEqualRotationVector(OrthancStone::LinearAlgebra::Product(r, a), b)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
606 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
607 OrthancStone::LinearAlgebra::AssignVector(a, 0, 0, 1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
608 OrthancStone::LinearAlgebra::AssignVector(b, 0, 0, 1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
609 OrthancStone::GeometryToolbox::AlignVectorsWithRotation(r, a, b); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
610 ASSERT_TRUE(OrthancStone::LinearAlgebra::IsRotationMatrix(r)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
611 ASSERT_TRUE(IsEqualRotationVector(OrthancStone::LinearAlgebra::Product(r, a), b)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
612 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
613 OrthancStone::LinearAlgebra::AssignVector(a, 0, 0, 0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
614 OrthancStone::LinearAlgebra::AssignVector(b, 0, 0, 1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
615 ASSERT_THROW(OrthancStone::GeometryToolbox::AlignVectorsWithRotation(r, a, b), Orthanc::OrthancException); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
616 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
617 // TODO: Deal with opposite vectors |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
618 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
619 /* |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
620 OrthancStone::LinearAlgebra::AssignVector(a, 0, 0, -1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
621 OrthancStone::LinearAlgebra::AssignVector(b, 0, 0, 1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
622 OrthancStone::GeometryToolbox::AlignVectorsWithRotation(r, a, b); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
623 OrthancStone::LinearAlgebra::Print(r); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
624 OrthancStone::LinearAlgebra::Print(boost::numeric::ublas::prod(r, a)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
625 */ |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
626 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
627 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
628 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
629 static bool IsEqualVectorL1(OrthancStone::Vector a, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
630 OrthancStone::Vector b) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
631 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
632 if (a.size() != b.size()) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
633 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
634 return false; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
635 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
636 else |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
637 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
638 for (size_t i = 0; i < a.size(); i++) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
639 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
640 if (!OrthancStone::LinearAlgebra::IsNear(a[i], b[i], 0.0001)) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
641 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
642 return false; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
643 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
644 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
645 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
646 return true; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
647 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
648 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
649 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
650 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
651 TEST(VolumeImageGeometry, Basic) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
652 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
653 using namespace OrthancStone; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
654 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
655 VolumeImageGeometry g; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
656 g.SetSizeInVoxels(10, 20, 30); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
657 g.SetVoxelDimensions(1, 2, 3); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
658 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
659 Vector p = g.GetCoordinates(0, 0, 0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
660 ASSERT_EQ(3u, p.size()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
661 ASSERT_DOUBLE_EQ(-1.0 / 2.0, p[0]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
662 ASSERT_DOUBLE_EQ(-2.0 / 2.0, p[1]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
663 ASSERT_DOUBLE_EQ(-3.0 / 2.0, p[2]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
664 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
665 p = g.GetCoordinates(1, 1, 1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
666 ASSERT_DOUBLE_EQ(-1.0 / 2.0 + 10.0 * 1.0, p[0]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
667 ASSERT_DOUBLE_EQ(-2.0 / 2.0 + 20.0 * 2.0, p[1]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
668 ASSERT_DOUBLE_EQ(-3.0 / 2.0 + 30.0 * 3.0, p[2]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
669 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
670 VolumeProjection proj; |
1766
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
671 bool isOpposite; |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
672 ASSERT_TRUE(g.DetectProjection(proj, isOpposite, g.GetAxialGeometry().GetNormal())); |
1679
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
673 ASSERT_EQ(VolumeProjection_Axial, proj); |
1766
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
674 ASSERT_FALSE(isOpposite); |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
675 ASSERT_TRUE(g.DetectProjection(proj, isOpposite, g.GetCoronalGeometry().GetNormal())); |
1679
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
676 ASSERT_EQ(VolumeProjection_Coronal, proj); |
1766
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
677 ASSERT_FALSE(isOpposite); |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
678 ASSERT_TRUE(g.DetectProjection(proj, isOpposite, g.GetSagittalGeometry().GetNormal())); |
1679
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
679 ASSERT_EQ(VolumeProjection_Sagittal, proj); |
1766
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
680 ASSERT_FALSE(isOpposite); |
1679
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
681 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
682 ASSERT_EQ(10u, g.GetProjectionWidth(VolumeProjection_Axial)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
683 ASSERT_EQ(20u, g.GetProjectionHeight(VolumeProjection_Axial)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
684 ASSERT_EQ(30u, g.GetProjectionDepth(VolumeProjection_Axial)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
685 ASSERT_EQ(10u, g.GetProjectionWidth(VolumeProjection_Coronal)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
686 ASSERT_EQ(30u, g.GetProjectionHeight(VolumeProjection_Coronal)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
687 ASSERT_EQ(20u, g.GetProjectionDepth(VolumeProjection_Coronal)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
688 ASSERT_EQ(20u, g.GetProjectionWidth(VolumeProjection_Sagittal)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
689 ASSERT_EQ(30u, g.GetProjectionHeight(VolumeProjection_Sagittal)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
690 ASSERT_EQ(10u, g.GetProjectionDepth(VolumeProjection_Sagittal)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
691 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
692 p = g.GetVoxelDimensions(VolumeProjection_Axial); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
693 ASSERT_EQ(3u, p.size()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
694 ASSERT_DOUBLE_EQ(1, p[0]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
695 ASSERT_DOUBLE_EQ(2, p[1]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
696 ASSERT_DOUBLE_EQ(3, p[2]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
697 p = g.GetVoxelDimensions(VolumeProjection_Coronal); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
698 ASSERT_EQ(3u, p.size()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
699 ASSERT_DOUBLE_EQ(1, p[0]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
700 ASSERT_DOUBLE_EQ(3, p[1]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
701 ASSERT_DOUBLE_EQ(2, p[2]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
702 p = g.GetVoxelDimensions(VolumeProjection_Sagittal); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
703 ASSERT_EQ(3u, p.size()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
704 ASSERT_DOUBLE_EQ(2, p[0]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
705 ASSERT_DOUBLE_EQ(3, p[1]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
706 ASSERT_DOUBLE_EQ(1, p[2]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
707 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
708 // Loop over all the voxels of the volume |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
709 for (unsigned int z = 0; z < g.GetDepth(); z++) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
710 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
711 const float zz = (0.5f + static_cast<float>(z)) / static_cast<float>(g.GetDepth()); // Z-center of the voxel |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
712 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
713 for (unsigned int y = 0; y < g.GetHeight(); y++) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
714 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
715 const float yy = (0.5f + static_cast<float>(y)) / static_cast<float>(g.GetHeight()); // Y-center of the voxel |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
716 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
717 for (unsigned int x = 0; x < g.GetWidth(); x++) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
718 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
719 const float xx = (0.5f + static_cast<float>(x)) / static_cast<float>(g.GetWidth()); // X-center of the voxel |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
720 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
721 const float sx = 1.0f; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
722 const float sy = 2.0f; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
723 const float sz = 3.0f; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
724 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
725 Vector p = g.GetCoordinates(xx, yy, zz); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
726 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
727 Vector q = (g.GetAxialGeometry().MapSliceToWorldCoordinates( |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
728 static_cast<double>(x) * sx, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
729 static_cast<double>(y) * sy) + |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
730 z * sz * g.GetAxialGeometry().GetNormal()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
731 ASSERT_TRUE(IsEqualVectorL1(p, q)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
732 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
733 q = (g.GetCoronalGeometry().MapSliceToWorldCoordinates( |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
734 static_cast<double>(x) * sx, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
735 static_cast<double>(g.GetDepth() - 1 - z) * sz) + |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
736 y * sy * g.GetCoronalGeometry().GetNormal()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
737 ASSERT_TRUE(IsEqualVectorL1(p, q)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
738 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
739 /** |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
740 * WARNING: In sagittal geometry, the normal points to |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
741 * REDUCING X-axis in the 3D world. This is necessary to keep |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
742 * the right-hand coordinate system. Hence the "-". |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
743 **/ |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
744 q = (g.GetSagittalGeometry().MapSliceToWorldCoordinates( |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
745 static_cast<double>(y) * sy, |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
746 static_cast<double>(g.GetDepth() - 1 - z) * sz) + |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
747 x * sx * (-g.GetSagittalGeometry().GetNormal())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
748 ASSERT_TRUE(IsEqualVectorL1(p, q)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
749 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
750 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
751 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
752 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
753 ASSERT_EQ(0, (int) VolumeProjection_Axial); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
754 ASSERT_EQ(1, (int) VolumeProjection_Coronal); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
755 ASSERT_EQ(2, (int) VolumeProjection_Sagittal); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
756 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
757 for (int p = 0; p < 3; p++) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
758 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
759 VolumeProjection projection = (VolumeProjection) p; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
760 const CoordinateSystem3D& s = g.GetProjectionGeometry(projection); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
761 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
762 ASSERT_THROW(g.GetProjectionSlice(projection, g.GetProjectionDepth(projection)), Orthanc::OrthancException); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
763 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
764 for (unsigned int i = 0; i < g.GetProjectionDepth(projection); i++) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
765 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
766 CoordinateSystem3D plane = g.GetProjectionSlice(projection, i); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
767 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
768 if (projection == VolumeProjection_Sagittal) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
769 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
770 ASSERT_TRUE(IsEqualVectorL1(plane.GetOrigin(), s.GetOrigin() + static_cast<double>(i) * |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
771 (-s.GetNormal()) * g.GetVoxelDimensions(projection)[2])); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
772 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
773 else |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
774 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
775 ASSERT_TRUE(IsEqualVectorL1(plane.GetOrigin(), s.GetOrigin() + static_cast<double>(i) * |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
776 s.GetNormal() * g.GetVoxelDimensions(projection)[2])); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
777 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
778 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
779 ASSERT_TRUE(IsEqualVectorL1(plane.GetAxisX(), s.GetAxisX())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
780 ASSERT_TRUE(IsEqualVectorL1(plane.GetAxisY(), s.GetAxisY())); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
781 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
782 unsigned int slice; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
783 VolumeProjection q; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
784 ASSERT_TRUE(g.DetectSlice(q, slice, plane)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
785 ASSERT_EQ(projection, q); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
786 ASSERT_EQ(i, slice); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
787 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
788 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
789 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
790 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
791 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
792 TEST(LinearAlgebra, ParseVectorLocale) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
793 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
794 OrthancStone::Vector v; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
795 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
796 ASSERT_TRUE(OrthancStone::LinearAlgebra::ParseVector(v, "1.2")); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
797 ASSERT_EQ(1u, v.size()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
798 ASSERT_DOUBLE_EQ(1.2, v[0]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
799 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
800 ASSERT_TRUE(OrthancStone::LinearAlgebra::ParseVector(v, "-1.2e+2")); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
801 ASSERT_EQ(1u, v.size()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
802 ASSERT_DOUBLE_EQ(-120.0, v[0]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
803 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
804 ASSERT_TRUE(OrthancStone::LinearAlgebra::ParseVector(v, "-1e-2\\2")); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
805 ASSERT_EQ(2u, v.size()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
806 ASSERT_DOUBLE_EQ(-0.01, v[0]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
807 ASSERT_DOUBLE_EQ(2.0, v[1]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
808 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
809 ASSERT_TRUE(OrthancStone::LinearAlgebra::ParseVector(v, "1.3671875\\1.3671875")); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
810 ASSERT_EQ(2u, v.size()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
811 ASSERT_DOUBLE_EQ(1.3671875, v[0]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
812 ASSERT_DOUBLE_EQ(1.3671875, v[1]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
813 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
814 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
815 TEST(GenericToolbox, NormalizeUuid) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
816 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
817 std::string ref("44ca5051-14ef-4d2f-8bd7-db20bfb61fbb"); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
818 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
819 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
820 std::string u("44ca5051-14ef-4d2f-8bd7-db20bfb61fbb"); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
821 OrthancStone::GenericToolbox::NormalizeUuid(u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
822 ASSERT_EQ(ref, u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
823 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
824 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
825 // space left |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
826 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
827 std::string u(" 44ca5051-14ef-4d2f-8bd7-db20bfb61fbb"); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
828 OrthancStone::GenericToolbox::NormalizeUuid(u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
829 ASSERT_EQ(ref, u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
830 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
831 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
832 // space right |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
833 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
834 std::string u("44ca5051-14ef-4d2f-8bd7-db20bfb61fbb "); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
835 OrthancStone::GenericToolbox::NormalizeUuid(u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
836 ASSERT_EQ(ref, u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
837 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
838 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
839 // space l & r |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
840 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
841 std::string u(" 44ca5051-14ef-4d2f-8bd7-db20bfb61fbb "); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
842 OrthancStone::GenericToolbox::NormalizeUuid(u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
843 ASSERT_EQ(ref, u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
844 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
845 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
846 // space left + case |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
847 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
848 std::string u(" 44CA5051-14ef-4d2f-8bd7-dB20bfb61fbb"); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
849 OrthancStone::GenericToolbox::NormalizeUuid(u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
850 ASSERT_EQ(ref, u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
851 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
852 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
853 // space right + case |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
854 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
855 std::string u("44ca5051-14EF-4D2f-8bd7-db20bfb61fbB "); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
856 OrthancStone::GenericToolbox::NormalizeUuid(u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
857 ASSERT_EQ(ref, u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
858 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
859 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
860 // space l & r + case |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
861 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
862 std::string u(" 44cA5051-14Ef-4d2f-8bD7-db20bfb61fbb "); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
863 OrthancStone::GenericToolbox::NormalizeUuid(u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
864 ASSERT_EQ(ref, u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
865 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
866 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
867 // no |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
868 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
869 std::string u(" 44ca5051-14ef-4d2f-8bd7- db20bfb61fbb"); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
870 OrthancStone::GenericToolbox::NormalizeUuid(u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
871 ASSERT_NE(ref, u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
872 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
873 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
874 // no |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
875 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
876 std::string u("44ca5051-14ef-4d2f-8bd7-db20bfb61fb"); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
877 OrthancStone::GenericToolbox::NormalizeUuid(u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
878 ASSERT_NE(ref, u); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
879 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
880 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
881 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
882 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
883 TEST(CoordinateSystem3D, Basic) |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
884 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
885 using namespace OrthancStone; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
886 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
887 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
888 CoordinateSystem3D c; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
889 ASSERT_FALSE(c.IsValid()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
890 ASSERT_DOUBLE_EQ(c.GetNormal()[0], 0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
891 ASSERT_DOUBLE_EQ(c.GetNormal()[1], 0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
892 ASSERT_DOUBLE_EQ(c.GetNormal()[2], 1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
893 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
894 ASSERT_DOUBLE_EQ(0, c.ComputeDistance(LinearAlgebra::CreateVector(0, 0, 0))); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
895 ASSERT_DOUBLE_EQ(0, c.ComputeDistance(LinearAlgebra::CreateVector(5, 0, 0))); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
896 ASSERT_DOUBLE_EQ(0, c.ComputeDistance(LinearAlgebra::CreateVector(0, 5, 0))); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
897 ASSERT_DOUBLE_EQ(5, c.ComputeDistance(LinearAlgebra::CreateVector(0, 0, 5))); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
898 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
899 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
900 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
901 CoordinateSystem3D c("nope1", "nope2"); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
902 ASSERT_FALSE(c.IsValid()); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
903 ASSERT_DOUBLE_EQ(c.GetNormal()[0], 0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
904 ASSERT_DOUBLE_EQ(c.GetNormal()[1], 0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
905 ASSERT_DOUBLE_EQ(c.GetNormal()[2], 1); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
906 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
907 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
908 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
909 // https://www.vedantu.com/maths/perpendicular-distance-of-a-point-from-a-plane |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
910 CoordinateSystem3D c = CoordinateSystem3D::CreateFromPlaneGeneralForm(2, 4, -4, -6); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
911 ASSERT_DOUBLE_EQ(3, c.ComputeDistance(LinearAlgebra::CreateVector(0, 3, 6))); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
912 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
913 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
914 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
915 // https://mathinsight.org/distance_point_plane_examples |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
916 CoordinateSystem3D c = CoordinateSystem3D::CreateFromPlaneGeneralForm(2, -2, 5, 8); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
917 ASSERT_DOUBLE_EQ(39.0 / sqrt(33.0), c.ComputeDistance(LinearAlgebra::CreateVector(4, -4, 3))); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
918 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
919 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
920 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
921 // https://www.ck12.org/calculus/distance-between-a-point-and-a-plane/lesson/Distance-Between-a-Point-and-a-Plane-MAT-ALY/ |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
922 const Vector a = LinearAlgebra::CreateVector(3, 6, 9); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
923 const Vector b = LinearAlgebra::CreateVector(9, 6, 3); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
924 const Vector c = LinearAlgebra::CreateVector(6, -9, 9); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
925 CoordinateSystem3D d = CoordinateSystem3D::CreateFromThreePoints(a, b, c); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
926 ASSERT_DOUBLE_EQ(0, d.ComputeDistance(a)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
927 ASSERT_DOUBLE_EQ(0, d.ComputeDistance(b)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
928 ASSERT_DOUBLE_EQ(0, d.ComputeDistance(c)); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
929 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
930 |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
931 { |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
932 // https://tutorial.math.lamar.edu/classes/calcii/eqnsofplanes.aspx |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
933 const Vector a = LinearAlgebra::CreateVector(1, -2, 0); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
934 const Vector b = LinearAlgebra::CreateVector(3, 1, 4); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
935 const Vector c = LinearAlgebra::CreateVector(0, -1, 2); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
936 CoordinateSystem3D d = CoordinateSystem3D::CreateFromThreePoints(a, b, c); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
937 double r = d.GetNormal() [0] / 2.0; |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
938 ASSERT_DOUBLE_EQ(-8 * r, d.GetNormal() [1]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
939 ASSERT_DOUBLE_EQ(5 * r, d.GetNormal() [2]); |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
940 } |
5b8b88e5bfd6
successfully running unit tests in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
941 } |
1765
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
942 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
943 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
944 TEST(SlicesSorter, HFP) |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
945 { |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
946 // 2021-04-27-repro-bug-HFP-HFS-cartman |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
947 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
948 { |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
949 // This is the last instance in the CT series ("InstanceNumber" is 368): |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
950 // CT1.2.752.243.1.1.20210202150623868.3730.61448.dcm |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
951 const OrthancStone::CoordinateSystem3D system("300\\302.5\\323.11", "-1\\0\\0\\0\\-1\\0"); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
952 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
953 /** |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
954 * The first instance in the series ("InstanceNumber" is 1) is |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
955 * CT1.2.752.243.1.1.20210202150623381.2000.76318.dcm, and its |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
956 * "ImagePositionPatient" is "300\\302.5\\690.11". It cannot be |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
957 * taken as the origin of the volume, otherwise the Z axis is |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
958 * shifted by the depth of the volume. |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
959 **/ |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
960 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
961 const double spacingXY = 1.171875; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
962 const double width = 512; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
963 const double height = 512; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
964 const double depth = 368; // Number of instances in the series |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
965 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
966 OrthancStone::VolumeImageGeometry geometry; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
967 geometry.SetAxialGeometry(system); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
968 geometry.SetSizeInVoxels(width, height, depth); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
969 geometry.SetVoxelDimensions(spacingXY, spacingXY, 1 /* pixel spacing Z */); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
970 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
971 OrthancStone::Vector p, q; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
972 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
973 p = OrthancStone::LinearAlgebra::CreateVector(0.5 / double(width), |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
974 0.5 / double(height), |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
975 0.5 / double(depth), 1); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
976 q = OrthancStone::LinearAlgebra::Product(geometry.GetTransform(), p); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
977 ASSERT_FLOAT_EQ(300, q[0]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
978 ASSERT_FLOAT_EQ(302.5, q[1]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
979 ASSERT_FLOAT_EQ(323.11, q[2]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
980 ASSERT_FLOAT_EQ(1, q[3]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
981 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
982 p = OrthancStone::LinearAlgebra::CreateVector((width - 0.5) / double(width), |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
983 (height - 0.5) / double(height), |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
984 (depth - 0.5) / double(depth), 1); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
985 q = OrthancStone::LinearAlgebra::Product(geometry.GetTransform(), p); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
986 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
987 ASSERT_FLOAT_EQ(300.0 - (width - 1.0) * spacingXY, q[0]); // "X" is swapped |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
988 ASSERT_FLOAT_EQ(302.5 - (height - 1.0) * spacingXY, q[1]); // "Y" is swapped |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
989 ASSERT_FLOAT_EQ(690.11, q[2]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
990 ASSERT_FLOAT_EQ(1, q[3]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
991 } |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
992 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
993 { |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
994 // DOSE instance: RD1.2.752.243.1.1.20210202150624529.3790.85357_DoseTPS.dcm |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
995 OrthancStone::CoordinateSystem3D system("-217.0492\\-161.4141\\376.61", "1\\0\\0\\0\\1\\0"); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
996 const double spacingXY = 3; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
997 const double width = 146; // Columns |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
998 const double height = 84; // Row |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
999 const double depth = 86; // Number of frames, same as the length of "GridFrameOffsetVector" |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1000 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1001 OrthancStone::VolumeImageGeometry geometry; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1002 geometry.SetAxialGeometry(system); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1003 geometry.SetSizeInVoxels(width, height, depth); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1004 geometry.SetVoxelDimensions(spacingXY, spacingXY, 3 /* pixel spacing Z, cf. "GridFrameOffsetVector" */); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1005 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1006 OrthancStone::Vector p, q; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1007 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1008 p = OrthancStone::LinearAlgebra::CreateVector(0.5 / double(width), 0.5 / double(height), 0.5 / double(depth), 1); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1009 q = OrthancStone::LinearAlgebra::Product(geometry.GetTransform(), p); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1010 ASSERT_FLOAT_EQ(-217.0492, q[0]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1011 ASSERT_FLOAT_EQ(-161.4141, q[1]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1012 ASSERT_FLOAT_EQ(376.61, q[2]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1013 ASSERT_FLOAT_EQ(1, q[3]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1014 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1015 p = OrthancStone::LinearAlgebra::CreateVector((width - 0.5) / double(width), |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1016 (height - 0.5) / double(height), |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1017 (depth - 0.5) / double(depth), 1); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1018 q = OrthancStone::LinearAlgebra::Product(geometry.GetTransform(), p); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1019 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1020 ASSERT_FLOAT_EQ(-217.0492 + (width - 1.0) * spacingXY, q[0]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1021 ASSERT_FLOAT_EQ(-161.4141 + (height - 1.0) * spacingXY, q[1]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1022 ASSERT_FLOAT_EQ(376.61 + 255.0 /* last item in "GridFrameOffsetVector" */, q[2]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1023 ASSERT_FLOAT_EQ(1, q[3]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1024 } |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1025 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1026 for (unsigned int upward = 0; upward < 2; upward++) |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1027 { |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1028 OrthancStone::SlicesSorter slices; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1029 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1030 for (unsigned int i = 0; i < 368; i++) |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1031 { |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1032 unsigned int z = (upward ? 323 + i : 690 - i); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1033 OrthancStone::CoordinateSystem3D p("300\\302.5\\" + boost::lexical_cast<std::string>(z) + ".11", |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1034 "-1\\0\\0\\0\\-1\\0"); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1035 slices.AddSlice(p, new Orthanc::SingleValueObject<unsigned int>(z)); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1036 } |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1037 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1038 slices.Sort(); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1039 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1040 double spacingZ; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1041 ASSERT_TRUE(slices.ComputeSpacingBetweenSlices(spacingZ)); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1042 ASSERT_FLOAT_EQ(1, spacingZ); |
1766
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1043 ASSERT_TRUE(slices.AreAllSlicesDistinct()); |
1765
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1044 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1045 ASSERT_FLOAT_EQ(300.0, slices.GetSliceGeometry(0).GetOrigin() [0]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1046 ASSERT_FLOAT_EQ(302.5, slices.GetSliceGeometry(0).GetOrigin() [1]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1047 ASSERT_FLOAT_EQ(323.11, slices.GetSliceGeometry(0).GetOrigin() [2]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1048 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1049 ASSERT_FLOAT_EQ(300.0, slices.GetSliceGeometry(367).GetOrigin() [0]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1050 ASSERT_FLOAT_EQ(302.5, slices.GetSliceGeometry(367).GetOrigin() [1]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1051 ASSERT_FLOAT_EQ(690.11, slices.GetSliceGeometry(367).GetOrigin() [2]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1052 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1053 ASSERT_EQ(323u, dynamic_cast<const Orthanc::SingleValueObject<unsigned int>&>(slices.GetSlicePayload(0)).GetValue()); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1054 ASSERT_EQ(690u, dynamic_cast<const Orthanc::SingleValueObject<unsigned int>&>(slices.GetSlicePayload(367)).GetValue()); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1055 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1056 const unsigned int width = 512; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1057 const unsigned int height = 512; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1058 const unsigned int depth = 368; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1059 const double spacingXY = 1.171875; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1060 |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1061 OrthancStone::VolumeImageGeometry geometry; |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1062 geometry.SetSizeInVoxels(width, height, depth); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1063 geometry.SetVoxelDimensions(spacingXY, spacingXY, 1); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1064 geometry.SetAxialGeometry(slices.GetSliceGeometry(0)); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1065 |
1766
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1066 OrthancStone::Vector q = geometry.GetCoordinates(0, 0, 0); |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1067 ASSERT_EQ(3u, q.size()); |
1765
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1068 ASSERT_FLOAT_EQ(300 + spacingXY / 2.0, q[0]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1069 ASSERT_FLOAT_EQ(302.5 + spacingXY / 2.0, q[1]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1070 ASSERT_FLOAT_EQ(323.11 - 0.5, q[2]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1071 |
1766
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1072 q = geometry.GetCoordinates(1, 1, 1); |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1073 ASSERT_EQ(3u, q.size()); |
1765
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1074 ASSERT_FLOAT_EQ(300 - double(width) * spacingXY + spacingXY / 2.0, q[0]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1075 ASSERT_FLOAT_EQ(302.5 - double(height) * spacingXY + spacingXY / 2.0, q[1]); |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1076 ASSERT_FLOAT_EQ(323.11 + 368.0 - 0.5, q[2]); |
1766
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1077 |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1078 OrthancStone::VolumeProjection projection; |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1079 unsigned int slice; |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1080 ASSERT_TRUE(geometry.DetectSlice(projection, slice, OrthancStone::CoordinateSystem3D("300\\302.5\\690.11", "-1\\0\\0\\0\\-1\\0"))); |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1081 ASSERT_EQ(OrthancStone::VolumeProjection_Axial, projection); |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1082 ASSERT_EQ(367u, slice); |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1083 ASSERT_TRUE(geometry.DetectSlice(projection, slice, OrthancStone::CoordinateSystem3D("300\\302.5\\323.11", "-1\\0\\0\\0\\-1\\0"))); |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1084 ASSERT_EQ(OrthancStone::VolumeProjection_Axial, projection); |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1085 ASSERT_EQ(0u, slice); |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1086 |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1087 // DOSE instance: RD1.2.752.243.1.1.20210202150624529.3790.85357_DoseTPS.dcm |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1088 ASSERT_TRUE(geometry.DetectSlice(projection, slice, |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1089 OrthancStone::CoordinateSystem3D("-217.0492\\-161.4141\\376.61", "1\\0\\0\\0\\1\\0"))); |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1090 ASSERT_EQ(OrthancStone::VolumeProjection_Axial, projection); |
ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1765
diff
changeset
|
1091 ASSERT_EQ(376u - 323u, slice); |
1765
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1092 } |
177f93c8371c
unit test SlicesSorter.HFP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
1093 } |
1961
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1094 |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1095 |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1096 TEST(GeometryToolbox, OrientationMarkers) |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1097 { |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1098 std::string top, bottom, left, right; |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1099 |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1100 OrthancStone::CoordinateSystem3D s; |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1101 ASSERT_FALSE(s.IsValid()); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1102 ASSERT_THROW(s.GetOrientationMarkers(top, bottom, left, right), Orthanc::OrthancException); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1103 |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1104 { |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1105 // BRAINIX series: 3ca69615-fcd4a4fb-e5f2cc9d-9c7a49a5-add98bbf |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1106 s = OrthancStone::CoordinateSystem3D( |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1107 "0\\0\\0", |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1108 "0.99971222877502\\7.8810308973E-12\\0.02398800104856\\-0.0017278126906\\0.99740260839462\\0.07200747728347"); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1109 ASSERT_TRUE(s.IsValid()); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1110 s.GetOrientationMarkers(top, bottom, left, right); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1111 ASSERT_EQ("AFL", top); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1112 ASSERT_EQ("PHR", bottom); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1113 ASSERT_EQ("RF", left); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1114 ASSERT_EQ("LH", right); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1115 } |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1116 |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1117 { |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1118 // BRAINIX series: dc0216d2-a406a5ad-31ef7a78-113ae9d9-29939f9e |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1119 s = OrthancStone::CoordinateSystem3D( |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1120 "0\\0\\0", |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1121 "0.99971222877502\\7.8810308973E-12\\0.02398800104856\\0.02392569556832\\0.07202820479869\\-0.9971156120300"); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1122 s.GetOrientationMarkers(top, bottom, left, right); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1123 ASSERT_EQ("HAR", top); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1124 ASSERT_EQ("FPL", bottom); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1125 ASSERT_EQ("RF", left); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1126 ASSERT_EQ("LH", right); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1127 } |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1128 |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1129 { |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1130 // ASSURANCETOURIX series: 1de00990-03680ef4-0be6bd5b-73a7d350-fb46abfa |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1131 s = OrthancStone::CoordinateSystem3D( |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1132 "0\\0\\0", |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1133 "1\\0\\0\\0\\1\\0"); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1134 s.GetOrientationMarkers(top, bottom, left, right); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1135 ASSERT_EQ("A", top); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1136 ASSERT_EQ("P", bottom); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1137 ASSERT_EQ("R", left); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1138 ASSERT_EQ("L", right); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1139 } |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1140 |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1141 { |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1142 // KNEE series: 4d04593b-953ced51-87e93f11-ae4cf03c-25defdcd |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1143 s = OrthancStone::CoordinateSystem3D( |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1144 "0\\0\\0", |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1145 "-0\\1\\0\\-0\\-0\\-1"); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1146 s.GetOrientationMarkers(top, bottom, left, right); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1147 ASSERT_EQ("H", top); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1148 ASSERT_EQ("F", bottom); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1149 ASSERT_EQ("A", left); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1150 ASSERT_EQ("P", right); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1151 } |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1152 |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1153 { |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1154 // KNEE series: 20b9d0c2-97d85e07-f4dbf4d2-f09e7e6a-0c19062e |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1155 s = OrthancStone::CoordinateSystem3D( |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1156 "0\\0\\0", |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1157 "0.999993\\-0.0036927\\0\\-0\\-0\\-1"); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1158 s.GetOrientationMarkers(top, bottom, left, right); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1159 ASSERT_EQ("H", top); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1160 ASSERT_EQ("F", bottom); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1161 ASSERT_EQ("RP", left); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1162 ASSERT_EQ("LA", right); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1163 } |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1164 |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1165 { |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1166 // KNEE series: f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1167 s = OrthancStone::CoordinateSystem3D( |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1168 "0\\0\\0", |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1169 "0.999841\\0.000366209\\0.0178227\\-0.000427244\\0.999995\\0.00326546"); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1170 s.GetOrientationMarkers(top, bottom, left, right); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1171 ASSERT_EQ("AFL", top); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1172 ASSERT_EQ("PHR", bottom); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1173 ASSERT_EQ("RFA", left); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1174 ASSERT_EQ("LHP", right); |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1175 } |
cbf54cd28d59
added CoordinateSystem3D::GetOrientationMarkers()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1877
diff
changeset
|
1176 } |