Search in sources :

Example 1 with RawSphericalHarmonics

use of org.orekit.forces.gravity.potential.RawSphericalHarmonicsProvider.RawSphericalHarmonics in project Orekit by CS-SI.

the class ReferenceFieldModel method nonCentralPart.

public Dfp nonCentralPart(final AbsoluteDate date, final Vector3D position) throws OrekitException {
    int degree = provider.getMaxDegree();
    int order = provider.getMaxOrder();
    // use coefficients without caring if they are the correct type
    final RawSphericalHarmonics harmonics = raw(provider).onDate(date);
    Dfp x = dfpField.newDfp(position.getX());
    Dfp y = dfpField.newDfp(position.getY());
    Dfp z = dfpField.newDfp(position.getZ());
    Dfp rho2 = x.multiply(x).add(y.multiply(y));
    Dfp rho = rho2.sqrt();
    Dfp r2 = rho2.add(z.multiply(z));
    Dfp r = r2.sqrt();
    Dfp aOr = dfpField.newDfp(provider.getAe()).divide(r);
    Dfp lambda = position.getX() > 0 ? dfpField.getTwo().multiply(DfpMath.atan(y.divide(rho.add(x)))) : dfpField.getPi().subtract(dfpField.getTwo().multiply(DfpMath.atan(y.divide(rho.subtract(x)))));
    Dfp cosTheta = z.divide(r);
    Dfp value = dfpField.getZero();
    Dfp aOrN = aOr;
    for (int n = 2; n <= degree; ++n) {
        Dfp sum = dfpField.getZero();
        for (int m = 0; m <= FastMath.min(n, order); ++m) {
            double cnm = harmonics.getRawCnm(n, m);
            double snm = harmonics.getRawSnm(n, m);
            Dfp mLambda = lambda.multiply(m);
            Dfp c = DfpMath.cos(mLambda).multiply(dfpField.newDfp(cnm));
            Dfp s = DfpMath.sin(mLambda).multiply(dfpField.newDfp(snm));
            Dfp pnm = alf[n][m].value(cosTheta);
            sum = sum.add(pnm.multiply(c.add(s)));
        }
        aOrN = aOrN.multiply(aOr);
        value = value.add(aOrN.multiply(sum));
    }
    return value.multiply(dfpField.newDfp(provider.getMu())).divide(r);
}
Also used : RawSphericalHarmonics(org.orekit.forces.gravity.potential.RawSphericalHarmonicsProvider.RawSphericalHarmonics) Dfp(org.hipparchus.dfp.Dfp)

Aggregations

Dfp (org.hipparchus.dfp.Dfp)1 RawSphericalHarmonics (org.orekit.forces.gravity.potential.RawSphericalHarmonicsProvider.RawSphericalHarmonics)1