00001 #pragma once 00002 /** 00003 * \file NETGeographicLib/SphericalCoefficients.h 00004 * \brief Header for NETGeographicLib::SphericalCoefficients class 00005 * 00006 * NETGeographicLib is copyright (c) Scott Heiman (2013) 00007 * GeographicLib is Copyright (c) Charles Karney (2010-2012) 00008 * <charles@karney.com> and licensed under the MIT/X11 License. 00009 * For more information, see 00010 * http://geographiclib.sourceforge.net/ 00011 **********************************************************************/ 00012 00013 namespace NETGeographicLib 00014 { 00015 /*! 00016 \brief .NET wrapper for GeographicLib::SphericalEngine::coeff. 00017 00018 This class allows .NET applications to access GeographicLib::SphericalEngine::coeff. 00019 00020 The SphericalHarmonic classes provide accessor functions that allow 00021 you to examine the coefficients. These accessor functions export a 00022 GeographicLib::SphericalEngine::coeff object. The GeographicLib::SphericalEngine 00023 class is not implemented in NETGeographicLib. SphericalCoefficients is provided as 00024 a substitute for GeographicLib::SphericalEngine::coeff allowing you to examine the 00025 coefficients in .NET applications. 00026 00027 Use SphericalHarmonic::Coefficients, SphericalHarmonic1::Coefficient*, 00028 or SphericalHarmonic2::Coefficient* to obtain an instance of this 00029 class. 00030 00031 <B>INTERFACE DIFFERENCES:</B><BR> 00032 This class does not implement readcoeffs. 00033 */ 00034 public ref class SphericalCoefficients 00035 { 00036 private: 00037 // The cosine coefficients. 00038 array<double>^ m_C; // size = Csize(m_nmx,m_mmx) 00039 // The sine coefficients 00040 array<double>^ m_S; // size = Ssize(m_nmx,m_mmx) 00041 // The dimension of the coefficients 00042 int m_N; 00043 int m_nmx; 00044 int m_mmx; 00045 public: 00046 /*! 00047 \brief Constructor. 00048 \param[in] c A reference to a GeographicLib::SphericalEngine::coeff object. 00049 This constructor is for internal use only. Developers should 00050 not create an instance of SphericalCoefficients. Use 00051 SphericalHarmonic::Coefficients, SphericalHarmonic1::Coefficient*, 00052 or SphericalHarmonic2::Coefficient* to obtain an instance of this 00053 class. 00054 */ 00055 SphericalCoefficients( const GeographicLib::SphericalEngine::coeff& c ); 00056 00057 /** 00058 * @return \e N the degree giving storage layout for \e C and \e S. 00059 **********************************************************************/ 00060 property int N { int get() { return m_N; } } 00061 /** 00062 * @return \e nmx the maximum degree to be used. 00063 **********************************************************************/ 00064 property int nmx { int get() { return m_nmx; } } 00065 /** 00066 * @return \e mmx the maximum order to be used. 00067 **********************************************************************/ 00068 property int mmx { int get() { return m_mmx; } } 00069 /** 00070 * The one-dimensional index into \e C and \e S. 00071 * 00072 * @param[in] n the degree. 00073 * @param[in] m the order. 00074 * @return the one-dimensional index. 00075 **********************************************************************/ 00076 int index(int n, int m) 00077 { return m * m_N - m * (m - 1) / 2 + n; } 00078 /** 00079 * An element of \e C. 00080 * 00081 * @param[in] k the one-dimensional index. 00082 * @return the value of the \e C coefficient. 00083 **********************************************************************/ 00084 double Cv(int k) { return m_C[k]; } 00085 /** 00086 * An element of \e S. 00087 * 00088 * @param[in] k the one-dimensional index. 00089 * @return the value of the \e S coefficient. 00090 **********************************************************************/ 00091 double Sv(int k) { return m_S[k - (m_N + 1)]; } 00092 /** 00093 * An element of \e C with checking. 00094 * 00095 * @param[in] k the one-dimensional index. 00096 * @param[in] n the requested degree. 00097 * @param[in] m the requested order. 00098 * @param[in] f a multiplier. 00099 * @return the value of the \e C coefficient multiplied by \e f in \e n 00100 * and \e m are in range else 0. 00101 **********************************************************************/ 00102 double Cv(int k, int n, int m, double f) 00103 { return m > m_mmx || n > m_nmx ? 0 : m_C[k] * f; } 00104 /** 00105 * An element of \e S with checking. 00106 * 00107 * @param[in] k the one-dimensional index. 00108 * @param[in] n the requested degree. 00109 * @param[in] m the requested order. 00110 * @param[in] f a multiplier. 00111 * @return the value of the \e S coefficient multiplied by \e f in \e n 00112 * and \e m are in range else 0. 00113 **********************************************************************/ 00114 double Sv(int k, int n, int m, double f) 00115 { return m > m_mmx || n > m_nmx ? 0 : m_S[k - (m_N + 1)] * f; } 00116 00117 /** 00118 * The size of the coefficient vector for the cosine terms. 00119 * 00120 * @param[in] N the maximum degree. 00121 * @param[in] M the maximum order. 00122 * @return the size of the vector of cosine terms as stored in column 00123 * major order. 00124 **********************************************************************/ 00125 static int Csize(int N, int M) 00126 { return (M + 1) * (2 * N - M + 2) / 2; } 00127 00128 /** 00129 * The size of the coefficient vector for the sine terms. 00130 * 00131 * @param[in] N the maximum degree. 00132 * @param[in] M the maximum order. 00133 * @return the size of the vector of cosine terms as stored in column 00134 * major order. 00135 **********************************************************************/ 00136 static int Ssize(int N, int M) 00137 { return Csize(N, M) - (N + 1); } 00138 00139 }; 00140 } // namespace NETGeographicLib