testCoordinateSystem.cc
Go to the documentation of this file.
1 
9 #include <utl/CoordinateSystem.h>
10 #include <utl/Vector.h>
11 #include <utl/TransformationMatrix.h>
12 #include <utl/GeometryException.h>
13 #include <utl/AugerUnits.h>
14 #include <tst/Verify.h>
15 
16 #include <cppunit/extensions/HelperMacros.h>
17 
22 
23 using namespace tst;
24 
25 
29 class TestCoordinateSystem : public CppUnit::TestFixture {
30 
31  CPPUNIT_TEST_SUITE(TestCoordinateSystem);
32  CPPUNIT_TEST(TestCoordinateSystemConstructor);
33  CPPUNIT_TEST(TestNewCoordinateSystemBase);
34  CPPUNIT_TEST(TestTransformationChaining);
35  CPPUNIT_TEST_SUITE_END();
36 
37 public:
38  void setUp() override { }
39 
40  void tearDown() override { }
41 
42  void
44  {
45  // commented since it was understood by g++ as a function forward decl
46  //const CoordinateSystem CoordDefault();
47  const CoordinateSystemPtr cDefault(CoordinateSystem::GetRootCoordinateSystem());
48  CoordinateSystem::RotationX(0, cDefault);
49  }
50 
51  void
53  {
54  const CoordinateSystemPtr cDefault(CoordinateSystem::GetRootCoordinateSystem());
55 
56  // DV: this number gets increased by the usage of geometry in the tests and can
57  // not be reliably predicted; disabling the test
58  //CPPUNIT_ASSERT(Verify<Equal>(CDefault.use_count(), 2L));
59  CPPUNIT_ASSERT(cDefault == CoordinateSystem::GetRootCoordinateSystem());
60 
61  const CoordinateSystemPtr c1(CoordinateSystem::RotationX(0, cDefault));
62  CPPUNIT_ASSERT(c1->GetReferenceSystem() == CoordinateSystem::GetRootCoordinateSystem());
63 
64  const CoordinateSystemPtr c2(BaseCoordinateSystem::RotationX(0, cDefault));
65  CPPUNIT_ASSERT(c2->GetReferenceSystem() == CoordinateSystem::GetRootCoordinateSystem());
66 
67  const CoordinateSystemPtr c3(CoordinateSystem::RotationX(0, c2));
68  CPPUNIT_ASSERT(c3->GetReferenceSystem() == c2);
69 
70  const CoordinateSystemPtr c4(CoordinateSystem::RotationX(0, c3));
71  // same base as c3
72  CPPUNIT_ASSERT(c4->GetReferenceSystem() == c2);
73  }
74 
75  void
77  {
78  using namespace utl;
79 
80  const CoordinateSystemPtr r = CoordinateSystem::GetRootCoordinateSystem();
81 
82  const Vector v(1*m, 0, 0, r);
83  const TransformationMatrix mra = TransformationMatrix::Translation(-1*m, 0, 0);
84  const CoordinateSystemPtr a = BaseCoordinateSystem::Translation(v, r);
85  const TransformationMatrix maa1 = TransformationMatrix::RotationZ(-33*deg);
86  const CoordinateSystemPtr a1 = CoordinateSystem::RotationZ(33*deg, a);
87  const TransformationMatrix maa2 = TransformationMatrix::RotationY(-33*deg);
88  const CoordinateSystemPtr a2 = BaseCoordinateSystem::RotationY(33*deg, a);
89  const TransformationMatrix ma2a2a = TransformationMatrix::RotationX(-33*deg);
90  const CoordinateSystemPtr a2a = CoordinateSystem::RotationX(33*deg, a2);
91 
92  const TransformationMatrix mrb = TransformationMatrix::RotationX(-90*deg);
93  const CoordinateSystemPtr b = BaseCoordinateSystem::RotationX(90*deg, r);
94  const TransformationMatrix mbb1 = TransformationMatrix::RotationY(-90*deg);
95  const CoordinateSystemPtr b1 = CoordinateSystem::RotationY(90*deg, b);
96  const TransformationMatrix mbb2 = TransformationMatrix::RotationZ(-90*deg)*mbb1;
97  const CoordinateSystemPtr b2 = CoordinateSystem::RotationZ(90*deg, b1);
98 
99  CPPUNIT_ASSERT(Verify<CloseTo>(mra.Distance(r->GetTransformationTo(a)), 0.));
100  CPPUNIT_ASSERT(Verify<CloseTo>(mra.Inverse().Distance(a->GetTransformationTo(r)), 0.));
101  CPPUNIT_ASSERT(Verify<CloseTo>(maa1.Distance(a->GetTransformationTo(a1)), 0.));
102  CPPUNIT_ASSERT(Verify<CloseTo>(r->GetTransformationTo(a1).Distance(maa1*mra), 0.));
103  CPPUNIT_ASSERT(Verify<CloseTo>(a1->GetTransformationTo(r).Distance(mra.Inverse()*maa1.Inverse()), 0.));
104  CPPUNIT_ASSERT(Verify<CloseTo>(r->GetTransformationTo(a2a).Distance(ma2a2a*maa2*mra), 0.));
105  CPPUNIT_ASSERT(Verify<CloseTo>(a2a->GetTransformationTo(r).Distance(mra.Inverse()*maa2.Inverse()*ma2a2a.Inverse()), 0.));
106  CPPUNIT_ASSERT(Verify<CloseTo>(a2a->GetTransformationTo(a1).Distance(maa1*maa2.Inverse()*ma2a2a.Inverse()), 0.));
107  CPPUNIT_ASSERT(Verify<CloseTo>(a1->GetInverseTransformationTo(a2a).Distance(maa1*maa2.Inverse()*ma2a2a.Inverse()), 0.));
108  CPPUNIT_ASSERT(Verify<CloseTo>(a1->GetTransformationTo(a2a).Distance(ma2a2a*maa2*maa1.Inverse()), 0.));
109 
110  CPPUNIT_ASSERT(Verify<CloseTo>(r->GetTransformationTo(b).Distance(mrb), 0.));
111  CPPUNIT_ASSERT(Verify<CloseTo>(b->GetTransformationTo(b1).Distance(mbb1), 0.));
112  CPPUNIT_ASSERT(Verify<CloseTo>(b->GetTransformationTo(b2).Distance(mbb2), 0.));
113 
114  CPPUNIT_ASSERT(Verify<CloseTo>(a1->GetTransformationTo(b2).Distance(mbb2*mrb*mra.Inverse()*maa1.Inverse()), 0.));
115  }
116 
117 };
118 
119 
TransformerConstructor< BaseCSPolicy > BaseCoordinateSystem
For base coordinate systems.
TransformerConstructor< DerivedCSPolicy > CoordinateSystem
The normal coordinate system type.
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
constexpr double deg
Definition: AugerUnits.h:140
Transformations matrices for afine transformations.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Vector object.
Definition: Vector.h:30
constexpr double m
Definition: AugerUnits.h:121

, generated on Tue Sep 26 2023.