16 #define BOOST_TEST_MODULE ( decomposer_test )
17 #include <boost/test/unit_test.hpp>
26 #include "Math/GenVector/Cartesian2D.h"
27 #include "Math/GenVector/Cartesian3D.h"
28 #include "Math/GenVector/PositionVector3D.h"
29 #include "Math/GenVector/DisplacementVector3D.h"
30 #include "Math/GenVector/DisplacementVector2D.h"
39 template <
typename Vector,
typename Po
int,
typename Proj>
49 using Projection_t =
typename Decomposer_t::Projection_t;
50 using Distance_t [[gnu::unused]] =
typename Decomposer_t::Distance_t;
51 using DecomposedVector_t =
typename Decomposer_t::DecomposedVector_t;
52 using AffinePlaneBase_t =
typename Decomposer_t::AffinePlaneBase_t;
57 static const Point3D_t Origin{ 0.0, 0.0, 0.0 };
58 static const Point3D_t ReferencePoint{ -5.0, 10.0, 15.0 };
59 static const Vector3D_t NullVector{ 0.0, 0.0, 0.0 };
60 static const Vector3D_t
Xaxis{ 1.0, 0.0, 0.0 };
61 static const Vector3D_t
Yaxis{ 0.0, 1.0, 0.0 };
62 static const Vector3D_t
Zaxis{ 0.0, 0.0, 1.0 };
80 Decomposer_t defaultBase;
81 BOOST_TEST(defaultBase.MainDir() ==
Xaxis);
82 BOOST_TEST(defaultBase.SecondaryDir() ==
Yaxis);
83 BOOST_TEST(defaultBase.NormalDir() ==
Zaxis);
84 BOOST_TEST(defaultBase.ReferencePoint() == Origin);
86 AffinePlaneBase_t rotatedBase(ReferencePoint,
Yaxis,
Zaxis);
88 Decomposer_t rotatedBase1_1(rotatedBase);
89 BOOST_TEST(rotatedBase1_1.MainDir() ==
Yaxis);
90 BOOST_TEST(rotatedBase1_1.SecondaryDir() ==
Zaxis);
91 BOOST_TEST(rotatedBase1_1.NormalDir() ==
Xaxis);
92 BOOST_TEST(rotatedBase1_1.ReferencePoint() == ReferencePoint);
94 Decomposer_t rotatedBase1_2(std::move(rotatedBase));
95 BOOST_TEST(rotatedBase1_2.MainDir() ==
Yaxis);
96 BOOST_TEST(rotatedBase1_2.SecondaryDir() ==
Zaxis);
97 BOOST_TEST(rotatedBase1_2.NormalDir() ==
Xaxis);
98 BOOST_TEST(rotatedBase1_2.ReferencePoint() == ReferencePoint);
104 AffinePlaneBase_t negativeBase(ReferencePoint,
Yaxis,
Xaxis);
128 defaultBase.SetBase(negativeBase);
129 BOOST_TEST(defaultBase.MainDir() ==
Yaxis);
130 BOOST_TEST(defaultBase.SecondaryDir() ==
Xaxis);
131 BOOST_TEST(defaultBase.NormalDir() == -
Zaxis);
132 BOOST_TEST(defaultBase.ReferencePoint() == ReferencePoint);
134 defaultBase.SetOrigin(Origin);
135 BOOST_TEST(defaultBase.MainDir() ==
Yaxis);
136 BOOST_TEST(defaultBase.SecondaryDir() ==
Xaxis);
137 BOOST_TEST(defaultBase.NormalDir() == -
Zaxis);
138 BOOST_TEST(defaultBase.ReferencePoint() == Origin);
140 defaultBase.SetMainDir(
Zaxis);
141 BOOST_TEST(defaultBase.MainDir() ==
Zaxis);
142 BOOST_TEST(defaultBase.SecondaryDir() ==
Xaxis);
143 BOOST_TEST(defaultBase.NormalDir() ==
Yaxis);
144 BOOST_TEST(defaultBase.ReferencePoint() == Origin);
146 defaultBase.SetSecondaryDir(
Yaxis);
147 BOOST_TEST(defaultBase.MainDir() ==
Zaxis);
148 BOOST_TEST(defaultBase.SecondaryDir() ==
Yaxis);
149 BOOST_TEST(defaultBase.NormalDir() == -
Xaxis);
150 BOOST_TEST(defaultBase.ReferencePoint() == Origin);
152 defaultBase.SetMainDir(
Xaxis);
153 BOOST_TEST(defaultBase.MainDir() ==
Xaxis);
154 BOOST_TEST(defaultBase.SecondaryDir() ==
Yaxis);
155 BOOST_TEST(defaultBase.NormalDir() ==
Zaxis);
156 BOOST_TEST(defaultBase.ReferencePoint() == Origin);
163 AffinePlaneBase_t decompBase(ReferencePoint,
Yaxis,
Zaxis);
164 Decomposer_t decomp(decompBase);
187 BOOST_TEST(decomp.ReferencePoint() == ReferencePoint);
188 BOOST_TEST(decomp.MainDir() ==
Yaxis);
189 BOOST_TEST(decomp.SecondaryDir() ==
Zaxis);
190 BOOST_TEST(decomp.NormalDir() ==
Xaxis);
191 BOOST_TEST(decomp.Base().Origin() == ReferencePoint);
192 BOOST_TEST(decomp.Base().MainDir() ==
Yaxis);
193 BOOST_TEST(decomp.Base().SecondaryDir() ==
Zaxis);
194 BOOST_TEST(decomp.Base().NormalDir() ==
Xaxis);
202 Point3D_t point(ReferencePoint + Vector3D_t(3.0, 4.0, 5.0));
227 BOOST_TEST(decomp.PointMainComponent (point) == 4.0,
tol);
228 BOOST_TEST(decomp.PointSecondaryComponent(point) == 5.0,
tol);
229 BOOST_TEST(decomp.PointNormalComponent (point) == 3.0,
tol);
232 auto proj = decomp.ProjectPointOnPlane(point);
233 BOOST_TEST(proj.X() == 4.0,
tol);
234 BOOST_TEST(proj.Y() == 5.0,
tol);
238 auto decomposed = decomp.DecomposePoint(point);
239 BOOST_TEST(decomposed.distance == 3.0,
tol);
240 BOOST_TEST(decomposed.projection.X() == 4.0,
tol);
241 BOOST_TEST(decomposed.projection.Y() == 5.0,
tol);
250 Vector3D_t
vector(2.0, 3.0, 4.0);
282 BOOST_TEST(decomp.VectorMainComponent (vector) == 3.0,
tol);
283 BOOST_TEST(decomp.VectorSecondaryComponent(vector) == 4.0,
tol);
284 BOOST_TEST(decomp.VectorNormalComponent (vector) == 2.0,
tol);
287 auto proj = decomp.ProjectVectorOnPlane(vector);
288 BOOST_TEST(proj.X() == 3.0,
tol);
289 BOOST_TEST(proj.Y() == 4.0,
tol);
293 auto decomposed = decomp.DecomposeVector(vector);
294 BOOST_TEST(decomposed.distance == 2.0,
tol);
295 BOOST_TEST(decomposed.projection.X() == 3.0,
tol);
296 BOOST_TEST(decomposed.projection.Y() == 4.0,
tol);
302 Projection_t proj(3.0, 4.0);
304 BOOST_TEST(decomp.MainComponent (proj) == 3.0,
tol);
305 BOOST_TEST(decomp.SecondaryComponent(proj) == 4.0,
tol);
312 DecomposedVector_t decomposed(
335 auto comp = decomp.ComposePoint(decomposed.distance, decomposed.projection);
336 BOOST_TEST(comp.X() == -2.0,
tol);
337 BOOST_TEST(comp.Y() == 14.0,
tol);
338 BOOST_TEST(comp.Z() == 20.0,
tol);
342 auto comp = decomp.ComposePoint(decomposed);
343 BOOST_TEST(comp.X() == -2.0,
tol);
344 BOOST_TEST(comp.Y() == 14.0,
tol);
345 BOOST_TEST(comp.Z() == 20.0,
tol);
354 auto comp = decomp.ComposeVector
355 (decomposed.distance, decomposed.projection);
356 BOOST_TEST(comp.X() == 3.0,
tol);
357 BOOST_TEST(comp.Y() == 4.0,
tol);
358 BOOST_TEST(comp.Z() == 5.0,
tol);
362 auto comp = decomp.ComposeVector(decomposed);
363 BOOST_TEST(comp.X() == 3.0,
tol);
364 BOOST_TEST(comp.Y() == 4.0,
tol);
365 BOOST_TEST(comp.Z() == 5.0,
tol);
375 StandardDecomposerTest<TVector3, TVector3, TVector2>();
382 using Point_t = ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>>;
384 = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>>;
386 = ROOT::Math::DisplacementVector2D<ROOT::Math::Cartesian2D<double>>;
388 StandardDecomposerTest<Vector_t, Point_t, Projection_t>();
Specializations of geo_vectors_utils.h for ROOT old vector types.
constexpr Vector Yaxis()
Returns a y axis vector of the specified type.
Class with methods to decompose and compose back vectors.
recob::tracking::Point_t Point_t
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Classes to project and compose a vector on a plane.
constexpr Vector Xaxis()
Returns a x axis vector of the specified type.
constexpr Vector Zaxis()
Returns a z axis vector of the specified type.
void StandardDecomposerTest()
recob::tracking::Vector_t Vector_t