Commit b6af0ac3 authored by Bryan Cazabonne's avatar Bryan Cazabonne
Browse files

Improved sine and cosine calculation.

parent e12fa0ea
Pipeline #796 passed with stage
in 31 minutes and 54 seconds
......@@ -21,6 +21,9 @@
</properties>
<body>
<release version="10.3" date="TBD" description="TBD">
<action dev="bryan" type="update" issue="741">
Updated Hipparchus version to 1.8 and updated code with new functionalities.
</action>
<action dev="thomas" type="add" issue="8">
Added Knocke's Earth rediffused radiation pressure force model.
</action>
......
......@@ -22,6 +22,7 @@ import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.geometry.euclidean.twod.Vector2D;
import org.hipparchus.util.FastMath;
import org.hipparchus.util.MathArrays;
import org.hipparchus.util.SinCos;
import org.orekit.frames.Frame;
import org.orekit.utils.TimeStampedPVCoordinates;
......@@ -158,7 +159,8 @@ public class Ellipse implements Serializable {
* @return ellipse point at theta, in underlying ellipsoid frame
*/
public Vector3D pointAt(final double theta) {
return toSpace(new Vector2D(a * FastMath.cos(theta), b * FastMath.sin(theta)));
final SinCos scTheta = FastMath.sinCos(theta);
return toSpace(new Vector2D(a * scTheta.cos(), b * scTheta.sin()));
}
/** Create a point from its ellipse-relative coordinates.
......
......@@ -22,6 +22,7 @@ import org.hipparchus.RealFieldElement;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.util.CompositeFormat;
import org.hipparchus.util.FastMath;
import org.hipparchus.util.FieldSinCos;
import org.hipparchus.util.MathUtils;
/** Point location relative to a 2D body surface, using {@link RealFieldElement}.
......@@ -112,13 +113,11 @@ public class FieldGeodeticPoint<T extends RealFieldElement<T>> {
*/
public FieldVector3D<T> getZenith() {
if (zenith == null) {
final T cosLat = latitude.cos();
final T sinLat = latitude.sin();
final T cosLon = longitude.cos();
final T sinLon = longitude.sin();
zenith = new FieldVector3D<>(cosLon.multiply(cosLat),
sinLon.multiply(cosLat),
sinLat);
final FieldSinCos<T> scLat = FastMath.sinCos(latitude);
final FieldSinCos<T> scLon = FastMath.sinCos(longitude);
zenith = new FieldVector3D<>(scLon.cos().multiply(scLat.cos()),
scLon.sin().multiply(scLat.cos()),
scLat.sin());
}
return zenith;
}
......@@ -143,13 +142,11 @@ public class FieldGeodeticPoint<T extends RealFieldElement<T>> {
*/
public FieldVector3D<T> getNorth() {
if (north == null) {
final T cosLat = latitude.cos();
final T sinLat = latitude.sin();
final T cosLon = longitude.cos();
final T sinLon = longitude.sin();
north = new FieldVector3D<>(cosLon.multiply(sinLat).negate(),
sinLon.multiply(sinLat).negate(),
cosLat);
final FieldSinCos<T> scLat = FastMath.sinCos(latitude);
final FieldSinCos<T> scLon = FastMath.sinCos(longitude);
north = new FieldVector3D<>(scLon.cos().multiply(scLat.sin()).negate(),
scLon.sin().multiply(scLat.sin()).negate(),
scLat.cos());
}
return north;
}
......@@ -174,8 +171,9 @@ public class FieldGeodeticPoint<T extends RealFieldElement<T>> {
*/
public FieldVector3D<T> getEast() {
if (east == null) {
east = new FieldVector3D<>(longitude.sin().negate(),
longitude.cos(),
final FieldSinCos<T> scLon = FastMath.sinCos(longitude);
east = new FieldVector3D<>(scLon.sin().negate(),
scLon.cos(),
longitude.getField().getZero());
}
return east;
......
......@@ -23,6 +23,7 @@ import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.CompositeFormat;
import org.hipparchus.util.FastMath;
import org.hipparchus.util.MathUtils;
import org.hipparchus.util.SinCos;
/** Point location relative to a 2D body surface.
* <p>Instance of this class are guaranteed to be immutable.</p>
......@@ -122,11 +123,9 @@ public class GeodeticPoint implements Serializable {
*/
public Vector3D getZenith() {
if (zenith == null) {
final double cosLat = FastMath.cos(latitude);
final double sinLat = FastMath.sin(latitude);
final double cosLon = FastMath.cos(longitude);
final double sinLon = FastMath.sin(longitude);
zenith = new Vector3D(cosLon * cosLat, sinLon * cosLat, sinLat);
final SinCos scLat = FastMath.sinCos(latitude);
final SinCos scLon = FastMath.sinCos(longitude);
zenith = new Vector3D(scLon.cos() * scLat.cos(), scLon.sin() * scLat.cos(), scLat.sin());
}
return zenith;
}
......@@ -151,11 +150,9 @@ public class GeodeticPoint implements Serializable {
*/
public Vector3D getNorth() {
if (north == null) {
final double cosLat = FastMath.cos(latitude);
final double sinLat = FastMath.sin(latitude);
final double cosLon = FastMath.cos(longitude);
final double sinLon = FastMath.sin(longitude);
north = new Vector3D(-cosLon * sinLat, -sinLon * sinLat, cosLat);
final SinCos scLat = FastMath.sinCos(latitude);
final SinCos scLon = FastMath.sinCos(longitude);
north = new Vector3D(-scLon.cos() * scLat.sin(), -scLon.sin() * scLat.sin(), scLat.cos());
}
return north;
}
......@@ -180,7 +177,8 @@ public class GeodeticPoint implements Serializable {
*/
public Vector3D getEast() {
if (east == null) {
east = new Vector3D(-FastMath.sin(longitude), FastMath.cos(longitude), 0);
final SinCos scLon = FastMath.sinCos(longitude);
east = new Vector3D(-scLon.sin(), scLon.cos(), 0);
}
return east;
}
......
......@@ -26,7 +26,9 @@ import org.hipparchus.geometry.euclidean.threed.Line;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.geometry.euclidean.twod.Vector2D;
import org.hipparchus.util.FastMath;
import org.hipparchus.util.FieldSinCos;
import org.hipparchus.util.MathArrays;
import org.hipparchus.util.SinCos;
import org.orekit.frames.FieldTransform;
import org.orekit.frames.Frame;
import org.orekit.frames.Transform;
......@@ -308,15 +310,13 @@ public class OneAxisEllipsoid extends Ellipsoid implements BodyShape {
/** {@inheritDoc} */
public Vector3D transform(final GeodeticPoint point) {
final double longitude = point.getLongitude();
final double cLambda = FastMath.cos(longitude);
final double sLambda = FastMath.sin(longitude);
final SinCos scLambda = FastMath.sinCos(longitude);
final double latitude = point.getLatitude();
final double cPhi = FastMath.cos(latitude);
final double sPhi = FastMath.sin(latitude);
final SinCos scPhi = FastMath.sinCos(latitude);
final double h = point.getAltitude();
final double n = getA() / FastMath.sqrt(1.0 - e2 * sPhi * sPhi);
final double r = (n + h) * cPhi;
return new Vector3D(r * cLambda, r * sLambda, (g2 * n + h) * sPhi);
final double n = getA() / FastMath.sqrt(1.0 - e2 * scPhi.sin() * scPhi.sin());
final double r = (n + h) * scPhi.cos();
return new Vector3D(r * scLambda.cos(), r * scLambda.sin(), (g2 * n + h) * scPhi.sin());
}
/** {@inheritDoc} */
......@@ -326,10 +326,12 @@ public class OneAxisEllipsoid extends Ellipsoid implements BodyShape {
final T longitude = point.getLongitude();
final T altitude = point.getAltitude();
final T cLambda = longitude.cos();
final T sLambda = longitude.sin();
final T cPhi = latitude.cos();
final T sPhi = latitude.sin();
final FieldSinCos<T> scLambda = FastMath.sinCos(longitude);
final FieldSinCos<T> scPhi = FastMath.sinCos(latitude);
final T cLambda = scLambda.cos();
final T sLambda = scLambda.sin();
final T cPhi = scPhi.cos();
final T sPhi = scPhi.sin();
final T n = sPhi.multiply(sPhi).multiply(e2).subtract(1.0).negate().sqrt().reciprocal().multiply(getA());
final T r = n.add(altitude).multiply(cPhi);
......
......@@ -23,6 +23,8 @@ import org.hipparchus.RealFieldElement;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
import org.hipparchus.util.FieldSinCos;
import org.hipparchus.util.SinCos;
import org.orekit.bodies.JPLEphemeridesLoader.EphemerisType;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.FieldAbsoluteDate;
......@@ -544,51 +546,70 @@ abstract class PredefinedIAUPoles implements IAUPole {
public Vector3D getPole(final AbsoluteDate date) {
final double d = d(date);
final double t = t(date);
final SinCos scE01 = FastMath.sinCos(FastMath.toRadians(d * E01_DOT + E01_0));
final SinCos scE02 = FastMath.sinCos(FastMath.toRadians(d * E02_DOT + E02_0));
final SinCos scE03 = FastMath.sinCos(FastMath.toRadians(d * E03_DOT + E03_0));
final SinCos scE04 = FastMath.sinCos(FastMath.toRadians(d * E04_DOT + E04_0));
final SinCos scE06 = FastMath.sinCos(FastMath.toRadians(d * E06_DOT + E06_0));
final SinCos scE10 = FastMath.sinCos(FastMath.toRadians(d * E10_DOT + E10_0));
final SinCos scE13 = FastMath.sinCos(FastMath.toRadians(d * E13_DOT + E13_0));
return new Vector3D(FastMath.toRadians(t * ALPHA_DOT + ALPHA_0 +
FastMath.sin(FastMath.toRadians(d * E01_DOT + E01_0)) * E01_SIN +
FastMath.sin(FastMath.toRadians(d * E02_DOT + E02_0)) * E02_SIN +
FastMath.sin(FastMath.toRadians(d * E03_DOT + E03_0)) * E03_SIN +
FastMath.sin(FastMath.toRadians(d * E04_DOT + E04_0)) * E04_SIN +
FastMath.sin(FastMath.toRadians(d * E06_DOT + E06_0)) * E06_SIN +
FastMath.sin(FastMath.toRadians(d * E10_DOT + E10_0)) * E10_SIN +
FastMath.sin(FastMath.toRadians(d * E13_DOT + E13_0)) * E13_SIN),
scE01.sin() * E01_SIN +
scE02.sin() * E02_SIN +
scE03.sin() * E03_SIN +
scE04.sin() * E04_SIN +
scE06.sin() * E06_SIN +
scE10.sin() * E10_SIN +
scE13.sin() * E13_SIN),
FastMath.toRadians(t * DELTA_DOT + DELTA_0 +
FastMath.cos(FastMath.toRadians(d * E01_DOT + E01_0)) * E01_COS +
FastMath.cos(FastMath.toRadians(d * E02_DOT + E02_0)) * E02_COS +
FastMath.cos(FastMath.toRadians(d * E03_DOT + E03_0)) * E03_COS +
FastMath.cos(FastMath.toRadians(d * E04_DOT + E04_0)) * E04_COS +
FastMath.cos(FastMath.toRadians(d * E06_DOT + E06_0)) * E06_COS +
FastMath.cos(FastMath.toRadians(d * E07_DOT + E07_0)) * E07_COS +
FastMath.cos(FastMath.toRadians(d * E10_DOT + E10_0)) * E10_COS +
FastMath.cos(FastMath.toRadians(d * E13_DOT + E13_0)) * E13_COS));
scE01.cos() * E01_COS +
scE02.cos() * E02_COS +
scE03.cos() * E03_COS +
scE04.cos() * E04_COS +
scE06.cos() * E06_COS +
FastMath.cos(FastMath.toRadians(d * E07_DOT + E07_0)) * E07_COS + // only the cosine is needed
scE10.cos() * E10_COS +
scE13.cos() * E13_COS));
}
/** {@inheritDoc} */
public <T extends RealFieldElement<T>> FieldVector3D<T> getPole(final FieldAbsoluteDate<T> date) {
final T d = d(date);
final T t = t(date);
final FieldSinCos<T> scE01 = FastMath.sinCos(FastMath.toRadians(d.multiply(E01_DOT).add(E01_0)));
final FieldSinCos<T> scE02 = FastMath.sinCos(FastMath.toRadians(d.multiply(E02_DOT).add(E02_0)));
final FieldSinCos<T> scE03 = FastMath.sinCos(FastMath.toRadians(d.multiply(E03_DOT).add(E03_0)));
final FieldSinCos<T> scE04 = FastMath.sinCos(FastMath.toRadians(d.multiply(E04_DOT).add(E04_0)));
final FieldSinCos<T> scE06 = FastMath.sinCos(FastMath.toRadians(d.multiply(E06_DOT).add(E06_0)));
final FieldSinCos<T> scE10 = FastMath.sinCos(FastMath.toRadians(d.multiply(E10_DOT).add(E10_0)));
final FieldSinCos<T> scE13 = FastMath.sinCos(FastMath.toRadians(d.multiply(E13_DOT).add(E13_0)));
return new FieldVector3D<>(FastMath.toRadians(t.multiply(ALPHA_DOT).add(ALPHA_0).
add(FastMath.toRadians(d.multiply(E01_DOT).add(E01_0)).sin().multiply(E01_SIN)).
add(FastMath.toRadians(d.multiply(E02_DOT).add(E02_0)).sin().multiply(E02_SIN)).
add(FastMath.toRadians(d.multiply(E03_DOT).add(E03_0)).sin().multiply(E03_SIN)).
add(FastMath.toRadians(d.multiply(E04_DOT).add(E04_0)).sin().multiply(E04_SIN)).
add(FastMath.toRadians(d.multiply(E06_DOT).add(E06_0)).sin().multiply(E06_SIN)).
add(FastMath.toRadians(d.multiply(E10_DOT).add(E10_0)).sin().multiply(E10_SIN)).
add(FastMath.toRadians(d.multiply(E13_DOT).add(E13_0)).sin().multiply(E13_SIN))),
add(scE01.sin().multiply(E01_SIN)).
add(scE02.sin().multiply(E02_SIN)).
add(scE03.sin().multiply(E03_SIN)).
add(scE04.sin().multiply(E04_SIN)).
add(scE06.sin().multiply(E06_SIN)).
add(scE10.sin().multiply(E10_SIN)).
add(scE13.sin().multiply(E13_SIN))),
FastMath.toRadians(t.multiply(DELTA_DOT).add(DELTA_0).
add(FastMath.toRadians(d.multiply(E01_DOT).add(E01_0)).cos().multiply(E01_COS)).
add(FastMath.toRadians(d.multiply(E02_DOT).add(E02_0)).cos().multiply(E02_COS)).
add(FastMath.toRadians(d.multiply(E03_DOT).add(E03_0)).cos().multiply(E03_COS)).
add(FastMath.toRadians(d.multiply(E04_DOT).add(E04_0)).cos().multiply(E04_COS)).
add(FastMath.toRadians(d.multiply(E06_DOT).add(E06_0)).cos().multiply(E06_COS)).
add(FastMath.toRadians(d.multiply(E07_DOT).add(E07_0)).cos().multiply(E07_COS)).
add(FastMath.toRadians(d.multiply(E10_DOT).add(E10_0)).cos().multiply(E10_COS)).
add(FastMath.toRadians(d.multiply(E13_DOT).add(E13_0)).cos().multiply(E13_COS))));
add(scE01.cos().multiply(E01_COS)).
add(scE02.cos().multiply(E02_COS)).
add(scE03.cos().multiply(E03_COS)).
add(scE04.cos().multiply(E04_COS)).
add(scE06.cos().multiply(E06_COS)).
add(FastMath.toRadians(d.multiply(E07_DOT).add(E07_0)).cos().multiply(E07_COS)).// only the cosine is needed
add(scE10.cos().multiply(E10_COS)).
add(scE13.cos().multiply(E13_COS))));
}
/** {@inheritDoc} */
public double getPrimeMeridianAngle(final AbsoluteDate date) {
final double d = d(date);
return FastMath.toRadians(d * (d * W_DOT_DOT + W_DOT) + W_0 +
FastMath.sin(FastMath.toRadians(d * E01_DOT + E01_0)) * E01_W_SIN +
FastMath.sin(FastMath.toRadians(d * E02_DOT + E02_0)) * E02_W_SIN +
......@@ -788,18 +809,24 @@ abstract class PredefinedIAUPoles implements IAUPole {
final double jd = FastMath.toRadians(t * JD_DOT + JD_0);
final double je = FastMath.toRadians(t * JE_DOT + JE_0);
final SinCos scJa = FastMath.sinCos(ja);
final SinCos scJb = FastMath.sinCos(jb);
final SinCos scJc = FastMath.sinCos(jc);
final SinCos scJd = FastMath.sinCos(jd);
final SinCos scJe = FastMath.sinCos(je);
return new Vector3D(FastMath.toRadians(t * ALPHA_DOT + ALPHA_0 +
FastMath.sin(ja) * JA_SIN +
FastMath.sin(jb) * JB_SIN +
FastMath.sin(jc) * JC_SIN +
FastMath.sin(jd) * JD_SIN +
FastMath.sin(je) * JE_SIN),
scJa.sin() * JA_SIN +
scJb.sin() * JB_SIN +
scJc.sin() * JC_SIN +
scJd.sin() * JD_SIN +
scJe.sin() * JE_SIN),
FastMath.toRadians(t * DELTA_DOT + DELTA_0 +
FastMath.cos(ja) * JA_COS +
FastMath.cos(jb) * JB_COS +
FastMath.cos(jc) * JC_COS +
FastMath.cos(jd) * JD_COS +
FastMath.cos(je) * JE_COS));
scJa.cos() * JA_COS +
scJb.cos() * JB_COS +
scJc.cos() * JC_COS +
scJd.cos() * JD_COS +
scJe.cos() * JE_COS));
}
/** {@inheritDoc} */
......@@ -812,18 +839,24 @@ abstract class PredefinedIAUPoles implements IAUPole {
final T jd = FastMath.toRadians(t.multiply(JD_DOT).add(JD_0));
final T je = FastMath.toRadians(t.multiply(JE_DOT).add(JE_0));
final FieldSinCos<T> scJa = FastMath.sinCos(ja);
final FieldSinCos<T> scJb = FastMath.sinCos(jb);
final FieldSinCos<T> scJc = FastMath.sinCos(jc);
final FieldSinCos<T> scJd = FastMath.sinCos(jd);
final FieldSinCos<T> scJe = FastMath.sinCos(je);
return new FieldVector3D<>(FastMath.toRadians(t.multiply(ALPHA_DOT).add(ALPHA_0).
add(ja.sin().multiply(JA_SIN)).
add(jb.sin().multiply(JB_SIN)).
add(jc.sin().multiply(JC_SIN)).
add(jd.sin().multiply(JD_SIN)).
add(je.sin().multiply(JE_SIN))),
add(scJa.sin().multiply(JA_SIN)).
add(scJb.sin().multiply(JB_SIN)).
add(scJc.sin().multiply(JC_SIN)).
add(scJd.sin().multiply(JD_SIN)).
add(scJe.sin().multiply(JE_SIN))),
FastMath.toRadians(t.multiply(DELTA_DOT).add(DELTA_0).
add(ja.cos().multiply(JA_COS)).
add(jb.cos().multiply(JB_COS)).
add(jc.cos().multiply(JC_COS)).
add(jd.cos().multiply(JD_COS)).
add(je.cos().multiply(JE_COS))));
add(scJa.cos().multiply(JA_COS)).
add(scJb.cos().multiply(JB_COS)).
add(scJc.cos().multiply(JC_COS)).
add(scJd.cos().multiply(JD_COS)).
add(scJe.cos().multiply(JE_COS))));
}
......@@ -989,16 +1022,18 @@ abstract class PredefinedIAUPoles implements IAUPole {
/** {@inheritDoc} */
public Vector3D getPole(final AbsoluteDate date) {
final double n = FastMath.toRadians(t(date) * N_DOT + N_0);
return new Vector3D(FastMath.toRadians(FastMath.sin(n) * ALPHA_SIN + ALPHA_0),
FastMath.toRadians(FastMath.cos(n) * DELTA_COS + DELTA_0));
final double n = FastMath.toRadians(t(date) * N_DOT + N_0);
final SinCos sc = FastMath.sinCos(n);
return new Vector3D(FastMath.toRadians(sc.sin() * ALPHA_SIN + ALPHA_0),
FastMath.toRadians(sc.cos() * DELTA_COS + DELTA_0));
}
/** {@inheritDoc} */
public <T extends RealFieldElement<T>> FieldVector3D<T> getPole(final FieldAbsoluteDate<T> date) {
final T n = FastMath.toRadians(t(date).multiply(N_DOT).add(N_0));
return new FieldVector3D<>(FastMath.toRadians(n.sin().multiply(ALPHA_SIN).add(ALPHA_0)),
FastMath.toRadians(n.cos().multiply(DELTA_COS).add(DELTA_0)));
final FieldSinCos<T> sc = FastMath.sinCos(n);
return new FieldVector3D<>(FastMath.toRadians(sc.sin().multiply(ALPHA_SIN).add(ALPHA_0)),
FastMath.toRadians(sc.cos().multiply(DELTA_COS).add(DELTA_0)));
}
/** {@inheritDoc} */
......
......@@ -20,7 +20,9 @@ import java.util.Arrays;
import org.hipparchus.RealFieldElement;
import org.hipparchus.util.FastMath;
import org.hipparchus.util.FieldSinCos;
import org.hipparchus.util.MathArrays;
import org.hipparchus.util.SinCos;
import org.orekit.errors.OrekitInternalError;
import org.orekit.utils.Constants;
......@@ -113,8 +115,7 @@ abstract class SeriesTerm {
// preliminary computation
final double tc = elements.getTC();
final double a = argument(elements);
final double sin = FastMath.sin(a);
final double cos = FastMath.cos(a);
final SinCos sc = FastMath.sinCos(a);
// compute each function
final double[] values = new double[sinCoeff.length];
......@@ -125,7 +126,7 @@ abstract class SeriesTerm {
s = s * tc + sinCoeff[i][j];
c = c * tc + cosCoeff[i][j];
}
values[i] = s * sin + c * cos;
values[i] = s * sc.sin() + c * sc.cos();
}
return values;
......@@ -142,8 +143,7 @@ abstract class SeriesTerm {
final double tc = elements.getTC();
final double a = argument(elements);
final double aDot = argumentDerivative(elements);
final double sin = FastMath.sin(a);
final double cos = FastMath.cos(a);
final SinCos sc = FastMath.sinCos(a);
// compute each function
final double[] derivatives = new double[sinCoeff.length];
......@@ -164,7 +164,7 @@ abstract class SeriesTerm {
sDot /= Constants.JULIAN_CENTURY;
cDot /= Constants.JULIAN_CENTURY;
}
derivatives[i] = (sDot - c * aDot) * sin + (cDot + s * aDot) * cos;
derivatives[i] = (sDot - c * aDot) * sc.sin() + (cDot + s * aDot) * sc.cos();
}
return derivatives;
......@@ -193,8 +193,7 @@ abstract class SeriesTerm {
// preliminary computation
final T tc = elements.getTC();
final T a = argument(elements);
final T sin = a.sin();
final T cos = a.cos();
final FieldSinCos<T> sc = FastMath.sinCos(a);
// compute each function
final T[] values = MathArrays.buildArray(tc.getField(), sinCoeff.length);
......@@ -205,7 +204,7 @@ abstract class SeriesTerm {
s = s.multiply(tc).add(sinCoeff[i][j]);
c = c.multiply(tc).add(cosCoeff[i][j]);
}
values[i] = s.multiply(sin).add(c.multiply(cos));
values[i] = s.multiply(sc.sin()).add(c.multiply(sc.cos()));
}
return values;
......@@ -223,8 +222,7 @@ abstract class SeriesTerm {
final T tc = elements.getTC();
final T a = argument(elements);
final T aDot = argumentDerivative(elements);
final T sin = a.sin();
final T cos = a.cos();
final FieldSinCos<T> sc = FastMath.sinCos(a);
// compute each function
final T[] derivatives = MathArrays.buildArray(tc.getField(), sinCoeff.length);
......@@ -245,8 +243,8 @@ abstract class SeriesTerm {
sDot = sDot.divide(Constants.JULIAN_CENTURY);
cDot = cDot.divide(Constants.JULIAN_CENTURY);
}
derivatives[i] = sDot.subtract(c.multiply(aDot)).multiply(sin).
add(cDot.add(s.multiply(aDot)).multiply(cos));
derivatives[i] = sDot.subtract(c.multiply(aDot)).multiply(sc.sin()).
add(cDot.add(s.multiply(aDot)).multiply(sc.cos()));
}
return derivatives;
......
......@@ -28,6 +28,7 @@ import org.hipparchus.geometry.euclidean.threed.Rotation;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
import org.hipparchus.util.Precision;
import org.hipparchus.util.SinCos;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitInternalError;
import org.orekit.forces.drag.DragSensitive;
......@@ -624,7 +625,8 @@ public class BoxAndSolarArraySpacecraft implements RadiationSensitive, DragSensi
if (referenceDate != null) {
// use a simple rotation at fixed rate
final double alpha = rotationRate * date.durationFrom(referenceDate);
return new Vector3D(FastMath.cos(alpha), saX, FastMath.sin(alpha), saY);
final SinCos scAlpha = FastMath.sinCos(alpha);
return new Vector3D(scAlpha.cos(), saX, scAlpha.sin(), saY);
}
// compute orientation for best lighting
......
......@@ -26,6 +26,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.hipparchus.util.FastMath;
import org.hipparchus.util.SinCos;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitMessages;
......@@ -181,10 +182,12 @@ public class FESCHatEpsilonReader extends OceanTidesReader {
// applying Equation (6.15), the ΔCn0 have the expected value but the
// ΔSn0 must be set to zero.
// (see ftp://tai.bipm.org/iers/convupdt/chapter6/icc6.pdf)
final double cPlus = commonFactor * termFactor * cHatPlus * FastMath.sin(ePlus + chiF);
final double sPlus = commonFactor * termFactor * cHatPlus * FastMath.cos(ePlus + chiF);
final double cMinus = (m == 0) ? 0.0 : commonFactor * termFactor * cHatMinus * FastMath.sin(eMinus + chiF);
final double sMinus = (m == 0) ? 0.0 : commonFactor * termFactor * cHatMinus * FastMath.cos(eMinus + chiF);
final SinCos scP = FastMath.sinCos(ePlus + chiF);
final SinCos scM = FastMath.sinCos(eMinus + chiF);
final double cPlus = commonFactor * termFactor * cHatPlus * scP.sin();
final double sPlus = commonFactor * termFactor * cHatPlus * scP.cos();
final double cMinus = (m == 0) ? 0.0 : commonFactor * termFactor * cHatMinus * scM.sin();
final double sMinus = (m == 0) ? 0.0 : commonFactor * termFactor * cHatMinus * scM.cos();
// store parsed fields
addWaveCoefficients(doodson, n, m, cPlus, sPlus, cMinus, sMinus, lineNumber, line);
......
......@@ -17,6 +17,7 @@
package org.orekit.forces.gravity.potential;
import org.hipparchus.util.FastMath;
import org.hipparchus.util.SinCos;
import org.orekit.data.BodiesElements;
/** Container for ocen tides coefficients for one tide wave.
......@@ -155,14 +156,13 @@ public class OceanTidesWave {
final double thetaF = cGamma * elements.getGamma() +
cL * elements.getL() + cLPrime * elements.getLPrime() + cF * elements.getF() +
cD * elements.getD() + cOmega * elements.getOmega();
final double cos = FastMath.cos(thetaF);
final double sin = FastMath.sin(thetaF);
final SinCos sc = FastMath.sinCos(thetaF);
for (int i = START_DEGREE; i <= degree; ++i) {
for (int j = 0; j <= FastMath.min(i, order); ++j) {
// from IERS conventions 2010, section 6.3, equation 6.15
cnm[i][j] += (cPlus[i][j] + cMinus[i][j]) * cos + (sPlus[i][j] + sMinus[i][j]) * sin;
snm[i][j] += (sPlus[i][j] - sMinus[i][j]) * cos - (cPlus[i][j] - cMinus[i][j]) * sin;
cnm[i][j] += (cPlus[i][j] + cMinus[i][j]) *