static void Main(string[] args)
 {
     try
     {
         int N = 3, N1 = 2, N2 = 1;                     // The maximum degrees
         double[] ca = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }; // cosine coefficients
         double[] sa = { 6, 5, 4, 3, 2, 1 }; // sine coefficients
         double[] cb = { 1, 2, 3, 4, 5, 6 };
         double[] sb = { 3, 2, 1 };
         double[] cc = { 2, 1 };
         double[] S2 = { 0 };
         double a = 1;
         SphericalHarmonic2 h = new SphericalHarmonic2(
                                 ca, sa, N, N, N, cb, sb, N1, N1, N1,
                                 cc, S2, N2, N2, 0, a,
                                 SphericalHarmonic2.Normalization.SCHMIDT);
         double tau1 = 0.1, tau2 = 0.05, x = 2, y = 3, z = 1;
         double v, vx, vy, vz;
         v = h.HarmonicSum(tau1, tau2, x, y, z, out vx, out vy, out vz);
         Console.WriteLine(String.Format("{0} {1} {2} {3}", v, vx, vy, vz));
     }
     catch (GeographicErr e)
     {
         Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
     }
 }
Example #2
0
 static void Main(string[] args)
 {
     try
     {
         int                N = 3, N1 = 2, N2 = 1;                  // The maximum degrees
         double[]           ca = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }; // cosine coefficients
         double[]           sa = { 6, 5, 4, 3, 2, 1 };              // sine coefficients
         double[]           cb = { 1, 2, 3, 4, 5, 6 };
         double[]           sb = { 3, 2, 1 };
         double[]           cc = { 2, 1 };
         double[]           S2 = { 0 };
         double             a  = 1;
         SphericalHarmonic2 h  = new SphericalHarmonic2(
             ca, sa, N, N, N, cb, sb, N1, N1, N1,
             cc, S2, N2, N2, 0, a,
             SphericalHarmonic2.Normalization.SCHMIDT);
         double tau1 = 0.1, tau2 = 0.05, x = 2, y = 3, z = 1;
         double v, vx, vy, vz;
         v = h.HarmonicSum(tau1, tau2, x, y, z, out vx, out vy, out vz);
         Console.WriteLine(String.Format("{0} {1} {2} {3}", v, vx, vy, vz));
     }
     catch (GeographicErr e)
     {
         Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
     }
 }
Example #3
0
 public SphericalHarmonicsPanel()
 {
     InitializeComponent();
     try
     {
         m_sh0 = new SphericalHarmonic(C, S, N, a, SphericalHarmonic.Normalization.SCHMIDT);
         m_sh1 = new SphericalHarmonic1(C, S, N, C1, S1, N1, a, SphericalHarmonic1.Normalization.FULL);
         m_sh2 = new SphericalHarmonic2(C, S, N, C1, S1, N1, C2, S2, N2, a, SphericalHarmonic2.Normalization.FULL);
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     m_classComboBox.SelectedIndex = 0;
 }
 public SphericalHarmonicsPanel()
 {
     InitializeComponent();
     try
     {
         m_sh0 = new SphericalHarmonic(C, S, N, a, SphericalHarmonic.Normalization.SCHMIDT);
         m_sh1 = new SphericalHarmonic1(C, S, N, C1, S1, N1, a, SphericalHarmonic1.Normalization.FULL);
         m_sh2 = new SphericalHarmonic2(C, S, N, C1, S1, N1, C2, S2, N2, a, SphericalHarmonic2.Normalization.FULL);
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     m_classComboBox.SelectedIndex = 0;
 }
Example #5
0
 private void OnValidate(object sender, EventArgs e)
 {
     try
     {
         const double      DEG_TO_RAD = 3.1415926535897932384626433832795 / 180.0;
         double            gradx, grady, gradz;
         SphericalHarmonic s0 = new SphericalHarmonic(C, S, N, N - 1, 0, a, SphericalHarmonic.Normalization.SCHMIDT);
         s0 = new SphericalHarmonic(C, S, N, a, SphericalHarmonic.Normalization.SCHMIDT);
         double sum  = s0.HarmonicSum(1.0, 2.0, 3.0);
         double test = s0.HarmonicSum(1.0, 2.0, 3.0, out gradx, out grady, out grady);
         if (sum != test)
         {
             throw new Exception("Error in SphericalHarmonic.HarmonicSum");
         }
         SphericalCoefficients sc = s0.Coefficients();
         CircularEngine        ce = s0.Circle(1.0, 0.5, true);
         sum  = ce.LongitudeSum(60.0);
         test = ce.LongitudeSum(Math.Cos(60.0 * DEG_TO_RAD), Math.Sin(60.0 * DEG_TO_RAD));
         if (sum != test)
         {
             throw new Exception("Error in CircularEngine.LongitudeSum 1");
         }
         test = ce.LongitudeSum(60.0, out gradx, out grady, out gradz);
         if (sum != test)
         {
             throw new Exception("Error in CircularEngine.LongitudeSum 2");
         }
         ce.LongitudeSum(Math.Cos(60.0 * DEG_TO_RAD), Math.Sin(60.0 * DEG_TO_RAD), out gradx, out grady, out gradz);
         if (sum != test)
         {
             throw new Exception("Error in CircularEngine.LongitudeSum 3");
         }
         SphericalHarmonic1 s1 = new SphericalHarmonic1(C, S, N, N - 1, 1, C1, S1, N1, N1 - 1, 0, a, SphericalHarmonic1.Normalization.SCHMIDT);
         s1   = new SphericalHarmonic1(C, S, N, C1, S1, N1, a, SphericalHarmonic1.Normalization.SCHMIDT);
         sum  = s1.HarmonicSum(0.95, 1.0, 2.0, 3.0);
         test = s1.HarmonicSum(0.95, 1.0, 2.0, 3.0, out gradx, out grady, out gradz);
         if (sum != test)
         {
             throw new Exception("Error in SphericalHarmonic1.HarmonicSum 3");
         }
         ce = s1.Circle(0.95, 1.0, 0.5, true);
         sc = s1.Coefficients();
         sc = s1.Coefficients1();
         SphericalHarmonic2 s2 = new SphericalHarmonic2(C, S, N, N - 1, 2, C1, S1, N1, N1 - 1, 1,
                                                        C2, S2, N2, N2 - 1, 0, a, SphericalHarmonic2.Normalization.SCHMIDT);
         s2   = new SphericalHarmonic2(C, S, N, C1, S1, N1, C2, S2, N2, a, SphericalHarmonic2.Normalization.SCHMIDT);
         sum  = s2.HarmonicSum(0.95, 0.8, 1.0, 2.0, 3.0);
         test = s2.HarmonicSum(0.95, 0.8, 1.0, 2.0, 3.0, out gradx, out grady, out gradz);
         if (sum != test)
         {
             throw new Exception("Error in SphericalHarmonic2.HarmonicSum 3");
         }
         ce = s2.Circle(0.95, 0.8, 1.0, 0.5, true);
         sc = s2.Coefficients();
         sc = s2.Coefficients1();
         sc = s2.Coefficients2();
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     MessageBox.Show("No errors found", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
 private void OnValidate(object sender, EventArgs e)
 {
     try
     {
         const double DEG_TO_RAD = 3.1415926535897932384626433832795 / 180.0;
         double gradx, grady, gradz;
         SphericalHarmonic s0 = new SphericalHarmonic(C, S, N, N - 1, 0, a, SphericalHarmonic.Normalization.SCHMIDT);
         s0 = new SphericalHarmonic(C, S, N, a, SphericalHarmonic.Normalization.SCHMIDT);
         double sum = s0.HarmonicSum(1.0, 2.0, 3.0);
         double test = s0.HarmonicSum(1.0, 2.0, 3.0, out gradx, out grady, out grady);
         if (sum != test)
             throw new Exception("Error in SphericalHarmonic.HarmonicSum");
         SphericalCoefficients sc = s0.Coefficients();
         CircularEngine ce = s0.Circle(1.0, 0.5, true);
         sum = ce.LongitudeSum(60.0);
         test = ce.LongitudeSum(Math.Cos(60.0 * DEG_TO_RAD), Math.Sin(60.0 * DEG_TO_RAD));
         if ( sum != test )
             throw new Exception("Error in CircularEngine.LongitudeSum 1");
         test = ce.LongitudeSum(60.0, out gradx, out grady, out gradz);
         if ( sum != test )
             throw new Exception("Error in CircularEngine.LongitudeSum 2");
         ce.LongitudeSum(Math.Cos(60.0 * DEG_TO_RAD), Math.Sin(60.0 * DEG_TO_RAD), out gradx, out grady, out gradz);
         if (sum != test)
             throw new Exception("Error in CircularEngine.LongitudeSum 3");
         SphericalHarmonic1 s1 = new SphericalHarmonic1(C, S, N, N - 1, 1, C1, S1, N1, N1 - 1, 0, a, SphericalHarmonic1.Normalization.SCHMIDT);
         s1 = new SphericalHarmonic1(C, S, N, C1, S1, N1, a, SphericalHarmonic1.Normalization.SCHMIDT);
         sum = s1.HarmonicSum(0.95, 1.0, 2.0, 3.0);
         test = s1.HarmonicSum(0.95, 1.0, 2.0, 3.0, out gradx, out grady, out gradz);
         if (sum != test)
             throw new Exception("Error in SphericalHarmonic1.HarmonicSum 3");
         ce = s1.Circle(0.95, 1.0, 0.5, true);
         sc = s1.Coefficients();
         sc = s1.Coefficients1();
         SphericalHarmonic2 s2 = new SphericalHarmonic2(C, S, N, N - 1, 2, C1, S1, N1, N1 - 1, 1,
             C2, S2, N2, N2 - 1, 0, a, SphericalHarmonic2.Normalization.SCHMIDT);
         s2 = new SphericalHarmonic2(C, S, N, C1, S1, N1, C2, S2, N2, a, SphericalHarmonic2.Normalization.SCHMIDT);
         sum = s2.HarmonicSum(0.95, 0.8, 1.0, 2.0, 3.0);
         test = s2.HarmonicSum(0.95, 0.8, 1.0, 2.0, 3.0, out gradx, out grady, out gradz);
         if (sum != test)
             throw new Exception("Error in SphericalHarmonic2.HarmonicSum 3");
         ce = s2.Circle(0.95, 0.8, 1.0, 0.5, true);
         sc = s2.Coefficients();
         sc = s2.Coefficients1();
         sc = s2.Coefficients2();
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     MessageBox.Show("No errors found", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }