testVector.cc
Go to the documentation of this file.
1 
10 #include <utl/CoordinateSystem.h>
11 #include <utl/Vector.h>
12 #include <utl/TransformationMatrix.h>
13 #include <utl/AugerUnits.h>
14 #include <tst/Verify.h>
15 #include <utl/Triple.h>
16 
17 #include <cppunit/extensions/HelperMacros.h>
18 
19 using namespace utl;
20 using namespace tst;
21 
22 
26 class testVector : public CppUnit::TestFixture {
27 
28  CPPUNIT_TEST_SUITE(testVector);
29  CPPUNIT_TEST(testVectorTransformation);
30  CPPUNIT_TEST(testVectorOperations);
31  CPPUNIT_TEST_SUITE_END();
32 
33 public:
34  void setUp() { }
35 
36  void tearDown() { }
37 
38  void
40  {
41  const CoordinateSystemPtr CS(CoordinateSystem::GetRootCoordinateSystem());
42  const Vector p(0,0,0, CS);
43 
44  const Vector t(1,0,0, CS);
46 
47  p.TransformTo(CTrans); // should not transform
48  CPPUNIT_ASSERT(p.GetCoordinateSystem() == CTrans);
49  CPPUNIT_ASSERT(Verify<CloseTo>(
50  p.GetCoordinates(CTrans), Triple(0,0,0)));
51  CPPUNIT_ASSERT(p.GetCoordinateSystem() == CTrans);
52  CPPUNIT_ASSERT(Verify<CloseTo>(
53  p.GetCoordinates(CS), Triple(0,0,0)));
54  CPPUNIT_ASSERT(p.GetCoordinateSystem() == CS);
55 
56  const Vector horizontal(1,0,0, CS);
58  horizontal.TransformTo(CRot);
59  CPPUNIT_ASSERT(horizontal.GetCoordinateSystem() == CRot);
60  CPPUNIT_ASSERT(Verify<CloseTo>(
61  horizontal.GetCoordinates(CRot), Triple(0,-1,0)));
62  CPPUNIT_ASSERT(horizontal.GetCoordinateSystem() == CRot);
63  CPPUNIT_ASSERT(Verify<CloseTo>(
64  horizontal.GetCoordinates(CS), Triple(1,0,0)));
65  CPPUNIT_ASSERT(horizontal.GetCoordinateSystem() == CS);
66  }
67 
68  void
70  {
71  const CoordinateSystemPtr CS(CoordinateSystem::GetRootCoordinateSystem());
72  const Vector o(0,0,0, CS);
73 
74  const Vector v1(1,2,3, CS);
75  Vector v2(3,2,1, CS);
76  v2 -= v1;
77  CPPUNIT_ASSERT(Verify<CloseTo>(
78  v2.GetCoordinates(CS), Triple(2,0,-2)));
79 
80  v2 += Vector(1,-1,3, CS);
81  CPPUNIT_ASSERT(Verify<CloseTo>(
82  v2.GetCoordinates(CS), Triple(3,-1,1)));
83 
84  const Vector v3(-v2);
85  CPPUNIT_ASSERT(Verify<CloseTo>(
86  v3.GetCoordinates(CS), Triple(-3,1,-1)));
87  }
88 
89 };
90 
91 
93 
94 
95 // Configure (x)emacs for this file ...
96 // Local Variables:
97 // mode:c++
98 // compile-command: "make -C .. -k run-testGeometry"
99 // End:
CoordinateSystemPtr GetCoordinateSystem() const
Get the coordinate system of the current internal representation.
Definition: BasicVector.h:234
void testVectorTransformation()
Definition: testVector.cc:39
void tearDown()
Definition: testVector.cc:36
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
constexpr double deg
Definition: AugerUnits.h:140
void testVectorOperations()
Definition: testVector.cc:69
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
boost::tuple< double, double, double > Triple
Coordinate triple for easy getting or setting of coordinates.
Definition: Triple.h:15
static Policy::type RotationZ(const double angle, const CoordinateSystemPtr &theCS)
Construct from rotation about Z axis.
static Policy::type Translation(const Vector &theTranslation, const CoordinateSystemPtr &theCS)
Construct from translation by vector.
Vector object.
Definition: Vector.h:30
void setUp()
Definition: testVector.cc:34

, generated on Tue Sep 26 2023.