OpenWalnut
1.4.0
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WUNITSPHERECOORDINATES_TEST_H 00026 #define WUNITSPHERECOORDINATES_TEST_H 00027 00028 #include <string> 00029 #include <vector> 00030 #include <algorithm> 00031 00032 #include <cxxtest/TestSuite.h> 00033 00034 #include "core/common/WLogger.h" 00035 #include "core/common/math/WGeometryFunctions.h" 00036 #include "core/common/math/WSymmetricSphericalHarmonic.h" 00037 00038 #include "../WUnitSphereCoordinates.h" 00039 00040 /** 00041 * Test class for the WUnitSphereCoordinates template. 00042 */ 00043 class WUnitSphereCoordinatesTest : public CxxTest::TestSuite 00044 { 00045 public: 00046 /** 00047 * Test implicit conversion between sphere and euclidean coordinates. 00048 */ 00049 void testSphereToEuclideanConversion() 00050 { 00051 // 1. test case 00052 WVector3d n( 1.0, 0.0, 0.0 ); 00053 WUnitSphereCoordinates< double > m( n ); 00054 WVector3d n2( m.getEuclidean() ); 00055 for( size_t i = 0; i < 3; i++ ) 00056 { 00057 TS_ASSERT_DELTA( n[ i ], n2[ i ], 0.001 ); 00058 } 00059 00060 // 2. test case 00061 n[ 0 ] = 1.0; 00062 n[ 1 ] = 0.5; 00063 n[ 2 ] = 1.0; 00064 m.setEuclidean( n ); 00065 n2 = m.getEuclidean(); 00066 n = normalize( n ); 00067 for( size_t i = 0; i < 3; i++ ) 00068 { 00069 TS_ASSERT_DELTA( n[ i ], n2[ i ], 0.001 ); 00070 } 00071 } 00072 00073 private: 00074 }; 00075 00076 #endif // WUNITSPHERECOORDINATES_TEST_H