OpenWalnut  1.5.0dev
WUnitSphereCoordinates_test.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WUNITSPHERECOORDINATES_TEST_H
26 #define WUNITSPHERECOORDINATES_TEST_H
27 
28 #include <string>
29 #include <vector>
30 #include <algorithm>
31 
32 #include <cxxtest/TestSuite.h>
33 
34 #include "core/common/WLogger.h"
35 #include "core/common/math/WGeometryFunctions.h"
36 #include "core/common/math/WSymmetricSphericalHarmonic.h"
37 
38 #include "../WUnitSphereCoordinates.h"
39 
40 /**
41  * Test class for the WUnitSphereCoordinates template.
42  */
43 class WUnitSphereCoordinatesTest : public CxxTest::TestSuite
44 {
45 public:
46  /**
47  * Test implicit conversion between sphere and euclidean coordinates.
48  */
50  {
51  // 1. test case
52  WVector3d n( 1.0, 0.0, 0.0 );
54  WVector3d n2( m.getEuclidean() );
55  for( size_t i = 0; i < 3; i++ )
56  {
57  TS_ASSERT_DELTA( n[ i ], n2[ i ], 0.001 );
58  }
59 
60  // 2. test case
61  n[ 0 ] = 1.0;
62  n[ 1 ] = 0.5;
63  n[ 2 ] = 1.0;
64  m.setEuclidean( n );
65  n2 = m.getEuclidean();
66  n = normalize( n );
67  for( size_t i = 0; i < 3; i++ )
68  {
69  TS_ASSERT_DELTA( n[ i ], n2[ i ], 0.001 );
70  }
71  }
72 
73 private:
74 };
75 
76 #endif // WUNITSPHERECOORDINATES_TEST_H
Test class for the WUnitSphereCoordinates template.
void testSphereToEuclideanConversion()
Test implicit conversion between sphere and euclidean coordinates.
This class stores coordinates on the unit sphere.
void setEuclidean(WMatrixFixed< T, 3, 1 > vector)
Returns the stored sphere coordinates as Euclidean coordinates.
WMatrixFixed< T, 3, 1 > getEuclidean() const
Returns the stored sphere coordinates as Euclidean coordinates.