CircularEngine.h 6.51 KB
Newer Older
Valentin Platzgummer's avatar
Valentin Platzgummer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
/**
 * \file NETGeographicLib/CircularEngine.h
 * \brief Header for NETGeographicLib::CircularEngine class
 *
 * NETGeographicLib is copyright (c) Scott Heiman (2013)
 * GeographicLib is Copyright (c) Charles Karney (2010-2012)
 * <charles@karney.com> and licensed under the MIT/X11 License.
 * For more information, see
 * https://geographiclib.sourceforge.io/
 **********************************************************************/
#pragma once

namespace NETGeographicLib
{
  /**
   * \brief .NET wrapper for GeographicLib::CircularEngine.
   *
   * This class allows .NET applications to access GeographicLib::CircularEngine.
   *
   * The class is a companion to SphericalEngine.  If the results of a
   * spherical harmonic sum are needed for several points on a circle of
   * constant latitude \e lat and height \e h, then SphericalEngine::Circle can
   * compute the inner sum, which is independent of longitude \e lon, and
   * produce a CircularEngine object.  CircularEngine::LongitudeSum() can
   * then be used to perform the outer sum for particular values of \e lon.
   * This can lead to substantial improvements in computational speed for high
   * degree sum (approximately by a factor of \e N / 2 where \e N is the
   * maximum degree).
   *
   * CircularEngine is tightly linked to the internals of SphericalEngine.  For
   * that reason, the constructor for this class is for internal use only.  Use
   * SphericalHarmonic::Circle, SphericalHarmonic1::Circle, and
   * SphericalHarmonic2::Circle to create instances of this class.
   *
   * CircularEngine stores the coefficients needed to allow the summation over
   * order to be performed in 2 or 6 vectors of length \e M + 1 (depending on
   * whether gradients are to be calculated).  For this reason the constructor
   * may throw a GeographicErr exception.
   *
   * C# Example:
   * \include example-CircularEngine.cs
   * Managed C++ Example:
   * \include example-CircularEngine.cpp
   * Visual Basic Example:
   * \include example-CircularEngine.vb
   *
   * <B>INTERFACE DIFFERENCES:</B><BR>
   * The () operator has been replaced with with LongitudeSum.
   *
   * This class does not have a constructor that can be used in a .NET
   * application.  Use SphericalHarmonic::Circle, SphericalHarmonic1::Circle or
   * SphericalHarmonic2::Circle to create instances of this class.
   **********************************************************************/
    public ref class CircularEngine
    {
        private:
        // pointer to the unmanaged GeographicLib::CircularEngine
        const GeographicLib::CircularEngine* m_pCircularEngine;

        // The finalizer frees the unmanaged memory when the object is destroyed.
        !CircularEngine();
    public:
        /**
         * The constructor.
         *
         * This constructor should not be used in .NET applications.
         * Use SphericalHarmonic::Circle, SphericalHarmonic1::Circle or
         * SphericalHarmonic2::Circle to create instances of this class.
         *
         * @param[in] c The unmanaged CircularEngine to be copied.
         **********************************************************************/
        CircularEngine( const GeographicLib::CircularEngine& c );

        /**
         * The destructor calls the finalizer
         **********************************************************************/
        ~CircularEngine()
        { this->!CircularEngine(); }

        /**
         * Evaluate the sum for a particular longitude given in terms of its
         * cosine and sine.
         *
         * @param[in] coslon the cosine of the longitude.
         * @param[in] sinlon the sine of the longitude.
         * @return \e V the value of the sum.
         *
         * The arguments must satisfy <i>coslon</i><sup>2</sup> +
         * <i>sinlon</i><sup>2</sup> = 1.
         **********************************************************************/
        double LongitudeSum(double coslon, double sinlon);

        /**
         * Evaluate the sum for a particular longitude.
         *
         * @param[in] lon the longitude (degrees).
         * @return \e V the value of the sum.
         **********************************************************************/
        double LongitudeSum(double lon);

        /**
         * Evaluate the sum and its gradient for a particular longitude given in
         * terms of its cosine and sine.
         *
         * @param[in] coslon the cosine of the longitude.
         * @param[in] sinlon the sine of the longitude.
         * @param[out] gradx \e x component of the gradient.
         * @param[out] grady \e y component of the gradient.
         * @param[out] gradz \e z component of the gradient.
         * @return \e V the value of the sum.
         *
         * The gradients will only be computed if the CircularEngine object was
         * created with this capability (e.g., via \e gradp = true in
         * SphericalHarmonic::Circle).  If not, \e gradx, etc., will not be
         * touched.  The arguments must satisfy <i>coslon</i><sup>2</sup> +
         * <i>sinlon</i><sup>2</sup> = 1.
         **********************************************************************/
        double LongitudeSum(double coslon, double sinlon,
                        [System::Runtime::InteropServices::Out] double% gradx,
                        [System::Runtime::InteropServices::Out] double% grady,
                        [System::Runtime::InteropServices::Out] double% gradz);

        /**
         * Evaluate the sum and its gradient for a particular longitude.
         *
         * @param[in] lon the longitude (degrees).
         * @param[out] gradx \e x component of the gradient.
         * @param[out] grady \e y component of the gradient.
         * @param[out] gradz \e z component of the gradient.
         * @return \e V the value of the sum.
         *
         * The gradients will only be computed if the CircularEngine object was
         * created with this capability (e.g., via \e gradp = true in
         * SphericalHarmonic::Circle).  If not, \e gradx, etc., will not be
         * touched.
         **********************************************************************/
        double LongitudeSum(double lon,
                    [System::Runtime::InteropServices::Out] double% gradx,
                    [System::Runtime::InteropServices::Out] double% grady,
                    [System::Runtime::InteropServices::Out] double% gradz);
    };
} //namespace NETGeographicLib