Commit f701f593 authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

replaced 86400 by Constants.JULIAN_DAY ...

parent af812dd1
......@@ -36,6 +36,7 @@ import org.orekit.time.AbsoluteDate;
import org.orekit.time.ChronologicalComparator;
import org.orekit.time.TimeScalesFactory;
import org.orekit.time.TimeStamped;
import org.orekit.utils.Constants;
import org.orekit.utils.PVCoordinates;
/** Loader for JPL ephemerides binary files (DE 405, DE 406).
......@@ -75,7 +76,7 @@ public class JPLEphemeridesLoader implements CelestialBodyLoader {
private static final String DEFAULT_SUPPORTED_NAMES = "^unx[mp](\\d\\d\\d\\d)\\.(?:(?:405)|(?:406))$";
/** 50 days in seconds. */
private static final double FIFTY_DAYS = 50 * 86400;
private static final double FIFTY_DAYS = 50 * Constants.JULIAN_DAY;
/** List of supported ephemerides types. */
public enum EphemerisType {
......@@ -434,7 +435,7 @@ public class JPLEphemeridesLoader implements CelestialBodyLoader {
}
final double au = getLoadedAstronomicalUnit();
return rawGM * au * au * au / (86400.0 * 86400.0);
return rawGM * au * au * au / (Constants.JULIAN_DAY * Constants.JULIAN_DAY);
}
......@@ -640,7 +641,7 @@ public class JPLEphemeridesLoader implements CelestialBodyLoader {
// compute chunks duration
final double timeSpan = extractDouble(record, 2668);
ok = ok && (timeSpan > 0) && (timeSpan < 100);
chunksDuration = 86400.0 * (timeSpan / chunks);
chunksDuration = Constants.JULIAN_DAY * (timeSpan / chunks);
if (Double.isNaN(maxChunksDuration)) {
maxChunksDuration = chunksDuration;
} else {
......@@ -783,7 +784,7 @@ public class JPLEphemeridesLoader implements CelestialBodyLoader {
* @return extracted date
*/
private static AbsoluteDate extractDate(final byte[] record, final int offset) {
final double dt = extractDouble(record, offset) * 86400;
final double dt = extractDouble(record, offset) * Constants.JULIAN_DAY;
return new AbsoluteDate(AbsoluteDate.JULIAN_EPOCH, dt, TimeScalesFactory.getTT());
}
......
......@@ -25,6 +25,7 @@ import org.orekit.frames.Transform;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.TimeScale;
import org.orekit.time.TimeScalesFactory;
import org.orekit.utils.Constants;
import org.orekit.utils.PVCoordinates;
import org.orekit.utils.PVCoordinatesProvider;
......@@ -742,7 +743,7 @@ public class JB2006 implements Atmosphere {
}
// compute modified julian days date
final double dateMJD = date.durationFrom(AbsoluteDate.MODIFIED_JULIAN_EPOCH) / 86400.;
final double dateMJD = date.durationFrom(AbsoluteDate.MODIFIED_JULIAN_EPOCH) / Constants.JULIAN_DAY;
// compute geodetic position
final GeodeticPoint inBody = earth.transform(position, frame, date);
......
......@@ -24,6 +24,7 @@ import org.orekit.data.BodiesElements;
import org.orekit.data.PoissonSeries;
import org.orekit.errors.OrekitException;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.Constants;
/** Celestial Intermediate Reference Frame 2000.
* <p>This frame includes both precession and nutation effects according to
......@@ -54,7 +55,7 @@ class CIRF2000Frame extends Frame {
private static final double RADIANS_PER_ARC_SECOND = Math.PI / 648000;
/** Julian century per second. */
private static final double JULIAN_CENTURY_PER_SECOND = 1.0 / (36525.0 * 86400.0);
private static final double JULIAN_CENTURY_PER_SECOND = 1.0 / (36525.0 * Constants.JULIAN_DAY);
// CHECKSTYLE: stop JavadocVariable check
......
......@@ -23,6 +23,7 @@ import java.util.List;
import org.apache.commons.math.geometry.Rotation;
import org.orekit.errors.OrekitException;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.Constants;
/** Factory for predefined reference frames.
......@@ -240,7 +241,7 @@ public class FramesFactory implements Serializable {
for (final EOP1980HistoryLoader loader : EOP_1980_LOADERS) {
loader.fillHistory(history);
}
history.checkEOPContinuity(5 * 86400.0);
history.checkEOPContinuity(5 * Constants.JULIAN_DAY);
return history;
}
......@@ -311,7 +312,7 @@ public class FramesFactory implements Serializable {
for (final EOP2000HistoryLoader loader : EOP_2000_LOADERS) {
loader.fillHistory(history);
}
history.checkEOPContinuity(5 * 86400.0);
history.checkEOPContinuity(5 * Constants.JULIAN_DAY);
return history;
}
......
......@@ -21,6 +21,7 @@ import org.apache.commons.math.geometry.Vector3D;
import org.orekit.errors.OrekitException;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.Constants;
/** International Terrestrial Reference Frame 2005.
......@@ -41,7 +42,7 @@ class ITRF2005Frame extends Frame {
private static final double RADIANS_PER_ARC_SECOND = TWO_PI / 1296000;
/** Julian century per second. */
private static final double JULIAN_CENTURY_PER_SECOND = 1.0 / (36525.0 * 86400.0);
private static final double JULIAN_CENTURY_PER_SECOND = 1.0 / (36525.0 * Constants.JULIAN_DAY);
/** S' rate in radians per julian century.
* Approximately -47 microarcsecond per julian century (Lambert and Bizouard, 2002)
......
......@@ -20,6 +20,7 @@ import org.apache.commons.math.geometry.Rotation;
import org.apache.commons.math.geometry.Vector3D;
import org.orekit.errors.OrekitException;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.Constants;
/** Mean Equator, Mean Equinox Frame.
* <p>This frame handles precession effects according to the IAU-76 model (Lieske).</p>
......@@ -37,7 +38,7 @@ class MEMEFrame extends Frame {
private static final double RADIANS_PER_ARC_SECOND = Math.PI / (180.0 * 3600.0);
/** Julian century per second. */
private static final double JULIAN_CENTURY_PER_SECOND = 1.0 / (36525.0 * 86400.0);
private static final double JULIAN_CENTURY_PER_SECOND = 1.0 / (36525.0 * Constants.JULIAN_DAY);
/** 1st coefficient for ZETA precession angle. */
private static final double ZETA_1 = 2306.2181 * RADIANS_PER_ARC_SECOND;
......
......@@ -23,6 +23,7 @@ import org.orekit.time.AbsoluteDate;
import org.orekit.time.DateComponents;
import org.orekit.time.TimeComponents;
import org.orekit.time.TimeScalesFactory;
import org.orekit.utils.Constants;
/** Pseudo Earth Fixed Frame.
* <p> This frame handles the sidereal time according to IAU-82 model.</p>
......@@ -41,7 +42,7 @@ class PEFFrame extends Frame {
private static final double TWO_PI = 2.0 * Math.PI;
/** Seconds per day. */
private static final double SECONDS_PER_DAY = 86400.;
private static final double SECONDS_PER_DAY = Constants.JULIAN_DAY;
/** Radians per second of time. */
private static final double RADIANS_PER_SECOND = TWO_PI / SECONDS_PER_DAY;
......
......@@ -20,6 +20,7 @@ import org.apache.commons.math.geometry.Rotation;
import org.apache.commons.math.geometry.Vector3D;
import org.orekit.errors.OrekitException;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.Constants;
/** True Equator, Mean Equinox of Date Frame.
* <p>This frame handles nutation effects according to the IAU-80 theory.</p>
......@@ -50,7 +51,7 @@ class TEMEFrame extends Frame {
private static final double RADIANS_PER_ARC_SECOND = Math.PI / 648000;
/** Julian century per second. */
private static final double JULIAN_CENTURY_PER_SECOND = 1.0 / (36525.0 * 86400.0);
private static final double JULIAN_CENTURY_PER_SECOND = 1.0 / (36525.0 * Constants.JULIAN_DAY);
// CHECKSTYLE: stop JavadocVariable check
......
......@@ -23,6 +23,7 @@ import org.orekit.time.AbsoluteDate;
import org.orekit.time.DateComponents;
import org.orekit.time.TimeComponents;
import org.orekit.time.TimeScalesFactory;
import org.orekit.utils.Constants;
/** Terrestrial Intermediate Reference Frame 2000.
* <p> The pole motion is not considered : Pseudo Earth Fixed Frame. It handles
......@@ -124,12 +125,12 @@ class TIRF2000Frame extends Frame {
final double dtu1 = eopHistory.getUT1MinusUTC(date);
final double utcMinusTai = TimeScalesFactory.getUTC().offsetFromTAI(date);
final double tu =
(date.durationFrom(ERA_REFERENCE) + utcMinusTai + dtu1 + tidalDtu1) / 86400.0;
(date.durationFrom(ERA_REFERENCE) + utcMinusTai + dtu1 + tidalDtu1) / Constants.JULIAN_DAY;
era = ERA_0 + ERA_1A * tu + ERA_1B * tu;
era -= TWO_PI * Math.floor((era + Math.PI) / TWO_PI);
// set up the transform from parent CIRF
final Vector3D rotationRate = new Vector3D((ERA_1A + ERA_1B) / 86400, Vector3D.PLUS_K);
final Vector3D rotationRate = new Vector3D((ERA_1A + ERA_1B) / Constants.JULIAN_DAY, Vector3D.PLUS_K);
setTransform(new Transform(new Rotation(Vector3D.PLUS_K, -era), rotationRate));
cachedDate = date;
......
......@@ -19,6 +19,7 @@ package org.orekit.frames;
import java.io.Serializable;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.Constants;
/** Compute tidal correction to the pole motion.
......@@ -242,7 +243,7 @@ public class TidalCorrection implements Serializable {
private void setInterpolatedCorrections(final AbsoluteDate date) {
final double t =
date.durationFrom(AbsoluteDate.MODIFIED_JULIAN_EPOCH) / 86400.0 - 37076.5;
date.durationFrom(AbsoluteDate.MODIFIED_JULIAN_EPOCH) / Constants.JULIAN_DAY - 37076.5;
final int n = dtRef.length;
final int nM12 = (n - 1) / 2;
......
......@@ -18,6 +18,8 @@ package org.orekit.time;
import java.io.Serializable;
import org.orekit.utils.Constants;
/** Holder for date and time components.
* <p>This class is a simple holder with no processing methods.</p>
* <p>Instance of this class are guaranteed to be immutable.</p>
......@@ -96,8 +98,8 @@ public class DateTimeComponents implements Serializable, Comparable<DateTimeComp
seconds += offset;
// fix range
final int dayShift = (int) Math.floor(seconds / 86400.0);
seconds -= 86400.0 * dayShift;
final int dayShift = (int) Math.floor(seconds / Constants.JULIAN_DAY);
seconds -= Constants.JULIAN_DAY * dayShift;
day += dayShift;
// set up components
......@@ -138,7 +140,7 @@ public class DateTimeComponents implements Serializable, Comparable<DateTimeComp
public double offsetFrom(final DateTimeComponents dateTime) {
final int dateOffset = date.getJ2000Day() - dateTime.date.getJ2000Day();
final double timeOffset = time.getSecondsInDay() - dateTime.time.getSecondsInDay();
return 86400.0 * dateOffset + timeOffset;
return Constants.JULIAN_DAY * dateOffset + timeOffset;
}
/** Get the date component.
......
......@@ -16,6 +16,8 @@
*/
package org.orekit.time;
import org.orekit.utils.Constants;
/** Barycentric Dynamic Time.
* <p>Time used to take account of time dilation when calculating orbits of planets,
* asteroids, comets and interplanetary spacecraft in the Solar system. It was based
......@@ -41,7 +43,7 @@ public class TDBScale implements TimeScale {
/** {@inheritDoc} */
public double offsetFromTAI(final AbsoluteDate date) {
final double dtDays = date.durationFrom(AbsoluteDate.J2000_EPOCH) / 86400;
final double dtDays = date.durationFrom(AbsoluteDate.J2000_EPOCH) / Constants.JULIAN_DAY;
final double g = Math.toRadians(357.53 + 0.9856003 * dtDays);
return TimeScalesFactory.getTT().offsetFromTAI(date) + (0.001658 * Math.sin(g) + 0.000014 * Math.sin(2 * g));
}
......
......@@ -24,6 +24,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.orekit.errors.OrekitException;
import org.orekit.utils.Constants;
/** Class representing a time within the day broken up as hour,
......@@ -92,12 +93,12 @@ public class TimeComponents implements Serializable, Comparable<TimeComponents>
}
/** Build a time from the second number within the day.
* @param secondInDay second number from 0.0 to 86400.0 (excluded)
* @param secondInDay second number from 0.0 to {@link Constants#JULIAN_DAY} (excluded)
* @exception IllegalArgumentException if seconds number is out of range
*/
public TimeComponents(final double secondInDay) {
// range check
if ((secondInDay < 0) || (secondInDay >= 86400.0)) {
if ((secondInDay < 0) || (secondInDay >= Constants.JULIAN_DAY)) {
throw OrekitException.createIllegalArgumentException("out of range seconds number: {0}",
secondInDay);
}
......@@ -171,7 +172,7 @@ public class TimeComponents implements Serializable, Comparable<TimeComponents>
}
/** Get the second number within the day.
* @return second number from 0.0 to 86400.0
* @return second number from 0.0 to Constants.JULIAN_DAY
*/
public double getSecondsInDay() {
return second + 60 * minute + 3600 * hour;
......
......@@ -20,6 +20,7 @@ import java.util.Map;
import java.util.SortedMap;
import org.orekit.errors.OrekitException;
import org.orekit.utils.Constants;
/** Coordinated Universal Time.
* <p>UTC is related to TAI using step adjustments from time to time
......@@ -100,7 +101,7 @@ public class UTCScale implements TimeScale {
/** {@inheritDoc} */
public synchronized double offsetToTAI(final DateComponents date,
final TimeComponents time) {
setCurrent(date.getJ2000Day() * 86400.0 + time.getSecondsInDay() - 43200);
setCurrent(date.getJ2000Day() * Constants.JULIAN_DAY + time.getSecondsInDay() - Constants.JULIAN_DAY / 2);
return offsets[current].getOffset();
}
......
......@@ -20,6 +20,7 @@ import org.apache.commons.math.util.MathUtils;
import org.orekit.errors.OrekitException;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.TimeScalesFactory;
import org.orekit.utils.Constants;
/** This class contains the methods that compute deep space perturbation terms.
......@@ -192,7 +193,7 @@ class DeepSDP4 extends SDP4 {
// Compute julian days since 1900
final double daysSince1900 =
(tle.getDate().durationFrom(AbsoluteDate.JULIAN_EPOCH) +
tle.getDate().timeScalesOffset(TimeScalesFactory.getUTC(), TimeScalesFactory.getTT())) / 86400.0 - 2415020;
tle.getDate().timeScalesOffset(TimeScalesFactory.getUTC(), TimeScalesFactory.getTT())) / Constants.JULIAN_DAY - 2415020;
double cc = C1SS;
......
......@@ -19,6 +19,7 @@ package org.orekit.tle;
import org.orekit.errors.OrekitException;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.TimeScalesFactory;
import org.orekit.utils.Constants;
/** This class contains methods to compute propagated coordinates with the SDP4 model.
* <p>
......@@ -120,11 +121,11 @@ abstract class SDP4 extends TLEPropagator {
final double omega_E = 1.00273790934;
final double jd = (date.durationFrom(AbsoluteDate.JULIAN_EPOCH) +
date.timeScalesOffset(TimeScalesFactory.getUTC(), TimeScalesFactory.getTT())
) / 86400;
) / Constants.JULIAN_DAY;
// Earth rotations per sidereal day (non-constant)
final double UT = (jd + 0.5) % 1;
final double seconds_per_day = 86400.;
final double seconds_per_day = Constants.JULIAN_DAY;
final double jd_2000 = 2451545.0; /* 1.5 Jan 2000 = JD 2451545. */
final double t_cen = (jd - UT - jd_2000) / 36525.;
double GMST = 24110.54841 +
......
......@@ -29,6 +29,7 @@ import org.orekit.time.TimeComponents;
import org.orekit.time.TimeScale;
import org.orekit.time.TimeScalesFactory;
import org.orekit.time.TimeStamped;
import org.orekit.utils.Constants;
/** This class is a container for a single set of TLE data.
*
......@@ -175,7 +176,7 @@ public class TLE implements TimeStamped, Serializable {
final DateComponents date = new DateComponents(parseYear(line1, 18), 1, 1);
final double dayNb = parseDouble(line1, 20, 12);
epoch = new AbsoluteDate(date, TimeComponents.H00,
TimeScalesFactory.getUTC()).shiftedBy((dayNb - 1) * 86400); //-1 is due to TLE date definition
TimeScalesFactory.getUTC()).shiftedBy((dayNb - 1) * Constants.JULIAN_DAY); //-1 is due to TLE date definition
// mean motion development
// converted from rev/day, 2 * rev/day^2 and 6 * rev/day^3 to rad/s, rad/s^2 and rad/s^3
......@@ -307,7 +308,7 @@ public class TLE implements TimeStamped, Serializable {
final TimeScale utc = TimeScalesFactory.getUTC();
final int year = epoch.getComponents(utc).getDate().getYear();
buffer.append(addPadding(year % 100, '0', 2, true));
final double day = 1.0 + epoch.durationFrom(new AbsoluteDate(year, 1, 1, utc)) / 86400;
final double day = 1.0 + epoch.durationFrom(new AbsoluteDate(year, 1, 1, utc)) / Constants.JULIAN_DAY;
buffer.append(f38.format(day));
buffer.append(' ');
......
......@@ -24,7 +24,7 @@ package org.orekit.utils;
public interface Constants {
/** Duration of a mean solar day: 86400 s. */
/** Duration of a mean solar day: Constants.JULIAN_DAY s. */
double JULIAN_DAY = 86400.0;
/** Speed of light: 299792458.0 m/s. */
......
......@@ -34,6 +34,7 @@ import org.orekit.time.AbsoluteDate;
import org.orekit.time.ChronologicalComparator;
import org.orekit.time.TimeScalesFactory;
import org.orekit.time.TimeStamped;
import org.orekit.utils.Constants;
/** This class reads and provides solar activity data needed by the
......@@ -179,22 +180,22 @@ public class SolarInputs97to05 implements JB2006InputParameters, DTM2000InputPar
private void findClosestLine(AbsoluteDate date) throws OrekitException {
if ((date.durationFrom(firstDate) < 0) || (date.durationFrom(lastDate) > 86400)) {
if ((date.durationFrom(firstDate) < 0) || (date.durationFrom(lastDate) > Constants.JULIAN_DAY)) {
throw new OrekitException("out of range" );
}
// don't search if the cached selection is fine
if ((currentParam != null) && (date.durationFrom(currentParam.date) >= 0) &&
(date.durationFrom(currentParam.date) < 86400 )) {
(date.durationFrom(currentParam.date) < Constants.JULIAN_DAY )) {
return;
}
LineParameters before = new LineParameters(date.shiftedBy(-86400), null, 0, 0, 0, 0, 0, 0);
LineParameters before = new LineParameters(date.shiftedBy(-Constants.JULIAN_DAY), null, 0, 0, 0, 0, 0, 0);
// search starting from entries a few steps before the target date
SortedSet<TimeStamped> tailSet = data.tailSet(before);
if (tailSet != null) {
currentParam = (LineParameters) tailSet.first();
if (currentParam.date.durationFrom(date) == -86400) {
if (currentParam.date.durationFrom(date) == -Constants.JULIAN_DAY) {
currentParam = (LineParameters) data.tailSet(date).first();
}
} else {
......@@ -286,7 +287,7 @@ public class SolarInputs97to05 implements JB2006InputParameters, DTM2000InputPar
}
public AbsoluteDate getMaxDate() {
return lastDate.shiftedBy(86400);
return lastDate.shiftedBy(Constants.JULIAN_DAY);
}
public AbsoluteDate getMinDate() {
......
......@@ -30,6 +30,7 @@ import org.orekit.time.AbsoluteDate;
import org.orekit.time.DateComponents;
import org.orekit.time.TimeComponents;
import org.orekit.time.TimeScalesFactory;
import org.orekit.utils.Constants;
import org.orekit.utils.PVCoordinates;
import org.orekit.utils.PVCoordinatesProvider;
......@@ -53,7 +54,7 @@ public class CelestialBodyPointingTest {
Assert.assertEquals(0,
Vector3D.dotProduct(zDirection, Vector3D.crossProduct(xDirection, Vector3D.PLUS_K)),
1.0e-15);
double period = 2 * Math.PI / (attitude.getSpin().getNorm() * 86400);
double period = 2 * Math.PI / (attitude.getSpin().getNorm() * Constants.JULIAN_DAY);
Assert.assertTrue((period > 350) && (period < 370));
// the following statement checks we take parallax into account
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment