Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

SHDevice.h

Go to the documentation of this file.
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 #ifndef _ZFXMATH_INCLUDE_SH_DEVICE_H_ 00015 #define _ZFXMATH_INCLUDE_SH_DEVICE_H_ 00016 00017 #include <assert.h> 00018 #include "SphericalHarmonics.h" 00019 #include "SHRotateMatrix.h" 00020 #include "SHRotate.h" 00021 #include "NRook.h" 00022 00023 namespace ZFXMath 00024 { 00025 00026 namespace SphericalHarmonics 00027 { 00028 00038 template< class PrecisionType, class FuncValueType > 00039 struct TDevice 00040 { 00052 TDevice( int numBands, int numSamples ) : 00053 m_NumBands( numBands ), 00054 m_NumSamples( numSamples ) 00055 { 00056 assert( numBands > 0 ); 00057 assert( numSamples > 0 ); 00058 00059 // Generate the sphere samples 00060 m_Samples = GenerateSamples<PrecisionType>( m_NumSamples ); 00061 00062 // Create an allocator with enough space to store y(l,m) over each band for each sample 00063 m_CoeffsAllocator = new TCoeffs<PrecisionType>::Allocator( m_NumSamples * m_NumBands * m_NumBands ); 00064 00065 // Allocate a set of empty coeff lists 00066 m_SHValues = new TCoeffs<PrecisionType>[m_NumSamples]; 00067 00068 for (int i = 0; i < m_NumSamples; i++) 00069 { 00070 // De-ref current sample 00071 TSample<PrecisionType>& s = m_Samples[i]; 00072 00073 // Create an SH coefficients to store the required number of bands 00074 TCoeffs<PrecisionType>& sh = m_SHValues[i] = TCoeffs<PrecisionType>( m_NumBands, m_CoeffsAllocator ); 00075 00076 // Record all y(l,m) for this sample 00077 for (int l = 0; l < m_NumBands; l++) 00078 for (int m = -l; m <= l; m++) 00079 sh(l, m) = y<PrecisionType>(l, m, s.theta, s.phi); 00080 } 00081 } 00082 00083 ~TDevice() 00084 { 00085 delete m_CoeffsAllocator; 00086 delete[] m_SHValues; 00087 } 00088 00100 void Project(const TSphericalFunction< PrecisionType, FuncValueType >& func, 00101 TCoeffs< FuncValueType >& dest ) 00102 { 00103 SphericalHarmonics::Project( func, m_Samples, m_SHValues, m_NumSamples, dest ); 00104 } 00105 00106 private: 00107 00108 // Number of samples on the sphere 00109 int m_NumSamples; 00110 00111 // Number of SH bands 00112 int m_NumBands; 00113 00114 // Uniformly distributed samples on the sphere 00115 TSample<PrecisionType>* m_Samples; 00116 00117 // Allocator for y(l,m) values for each sample 00118 typename TCoeffs<PrecisionType>::Allocator* m_CoeffsAllocator; 00119 00120 // y(l,m) stored for each sample over m_NumBands 00121 TCoeffs<PrecisionType>* m_SHValues; 00122 00123 }; 00124 00125 }; // namespace SphericalHarmonics 00126 00127 }; // namespace ZFXMath 00128 00129 #endif //_ZFXMATH_INCLUDE_SH_DEVICE_H__

Generated on Thu Nov 25 04:02:58 2004 for ZFX-Math Library by doxygen 1.3.8