Example usage for org.apache.commons.math3.dfp DfpMath sin

List of usage examples for org.apache.commons.math3.dfp DfpMath sin

Introduction

In this page you can find the example usage for org.apache.commons.math3.dfp DfpMath sin.

Prototype

public static Dfp sin(final Dfp a) 

Source Link

Document

computes the sine of the argument.

Usage

From source file:org.orekit.forces.gravity.ReferenceFieldModel.java

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();//from w  w w.j a  va2s .  c o  m
    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);

}