testOperationsVV.cc
Go to the documentation of this file.
1 
10 #include <utl/Vector.h>
11 #include <utl/MathConstants.h>
12 
13 #include <tst/Verify.h>
14 #include <utl/Triple.h>
15 
16 #include <cppunit/extensions/HelperMacros.h>
17 
18 using namespace utl;
19 using namespace tst;
20 
21 
25 class testOperationsVV : public CppUnit::TestFixture {
26 
27  CPPUNIT_TEST_SUITE(testOperationsVV);
28  CPPUNIT_TEST(testVectorOperations);
29  CPPUNIT_TEST_SUITE_END();
30 
31 public:
32  void setUp() { }
33 
34  void tearDown() { }
35 
36  void
38  {
39  const CoordinateSystemPtr CS(CoordinateSystem::GetRootCoordinateSystem());
40  const Vector v1(1,0,0, CS);
41  const Vector v2(0,1,0, CS);
42  const Vector v3(v1 + v2);
43  CPPUNIT_ASSERT(Verify<CloseTo>(
44  v3.GetCoordinates(CS), Triple(1,1,0)));
45 
46  const Vector v4(v1 - v2);
47  CPPUNIT_ASSERT(Verify<CloseTo>(
48  v4.GetCoordinates(CS), Triple(1,-1,0)));
49 
50  const Vector v5(2 * (v1 + v2));
51  CPPUNIT_ASSERT(Verify<CloseTo>(
52  v5.GetCoordinates(CS), Triple(2,2,0)));
53 
54  const Vector v6(2 * v1 - v2 * 3);
55  CPPUNIT_ASSERT(Verify<CloseTo>(
56  v6.GetCoordinates(CS), Triple(2,-3,0)));
57 
58  const Vector v7(v5 / 2);
59  CPPUNIT_ASSERT(Verify<CloseTo>(
60  v7.GetCoordinates(CS), Triple(1,1,0)));
61 
62  CPPUNIT_ASSERT(Verify<CloseTo>(Angle(v1, v2), kPi/2));
63  CPPUNIT_ASSERT(Verify<CloseTo>(Angle(v1, v3), kPi/4));
64 
65  CPPUNIT_ASSERT(Verify<CloseTo>(Angle(v1, v1), 0.));
66  CPPUNIT_ASSERT(Verify<CloseTo>(Angle(v2, v2), 0.));
67  CPPUNIT_ASSERT(Verify<CloseTo>(Angle(v3, v3), 0.));
68  }
69 
70 };
71 
72 
74 
75 
76 // Configure (x)emacs for this file ...
77 // Local Variables:
78 // mode: c++
79 // compile-command: "make -C .. -k run-testGeometry"
80 // End:
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
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
constexpr double kPi
Definition: MathConstants.h:24
double Angle(const Vector &left, const Vector &right)
Definition: OperationsVV.h:82
Vector object.
Definition: Vector.h:30

, generated on Tue Sep 26 2023.