List of usage examples for org.apache.commons.math3.util FastMath IEEEremainder
public static double IEEEremainder(double dividend, double divisor)
From source file:org.orekit.bodies.JPLEphemeridesLoader.java
/** Parse the first header record. * @param record first header record//from ww w . j a v a 2 s.co m * @param name name of the file (or zip entry) * @exception OrekitException if the header is not a JPL ephemerides binary file header */ private void parseFirstHeaderRecord(final byte[] record, final String name) throws OrekitException { // get the ephemerides type final int deNum = extractInt(record, HEADER_EPHEMERIS_TYPE_OFFSET); // as default, 3 polynomial coefficients for the cartesian coordinates // (x, y, z) are contained in the file, positions are in kilometers // and times are in TDB components = 3; positionUnit = 1000.0; timeScale = TimeScalesFactory.getTDB(); if (deNum == INPOP_DE_NUMBER) { // an INPOP file may contain 6 components (including coefficients for the velocity vector) final double format = getLoadedConstant("FORMAT"); if (!Double.isNaN(format) && (int) FastMath.IEEEremainder(format, 10) != 1) { components = 6; } // INPOP files may have their polynomials expressed in AU final double unite = getLoadedConstant("UNITE"); if (!Double.isNaN(unite) && (int) unite == 0) { positionUnit = getLoadedAstronomicalUnit(); } // INPOP files may have their times expressed in TCB final double timesc = getLoadedConstant("TIMESC"); if (!Double.isNaN(timesc) && (int) timesc == 1) { timeScale = TimeScalesFactory.getTCB(); } } // extract covered date range startEpoch = extractDate(record, HEADER_START_EPOCH_OFFSET); finalEpoch = extractDate(record, HEADER_END_EPOCH_OFFSET); boolean ok = finalEpoch.compareTo(startEpoch) > 0; // indices of the Chebyshev coefficients for each ephemeris for (int i = 0; i < 12; ++i) { final int row1 = extractInt(record, HEADER_CHEBISHEV_INDICES_OFFSET + 12 * i); final int row2 = extractInt(record, HEADER_CHEBISHEV_INDICES_OFFSET + 4 + 12 * i); final int row3 = extractInt(record, HEADER_CHEBISHEV_INDICES_OFFSET + 8 + 12 * i); ok = ok && (row1 >= 0) && (row2 >= 0) && (row3 >= 0); if (((i == 0) && (loadType == EphemerisType.MERCURY)) || ((i == 1) && (loadType == EphemerisType.VENUS)) || ((i == 2) && (loadType == EphemerisType.EARTH_MOON)) || ((i == 3) && (loadType == EphemerisType.MARS)) || ((i == 4) && (loadType == EphemerisType.JUPITER)) || ((i == 5) && (loadType == EphemerisType.SATURN)) || ((i == 6) && (loadType == EphemerisType.URANUS)) || ((i == 7) && (loadType == EphemerisType.NEPTUNE)) || ((i == 8) && (loadType == EphemerisType.PLUTO)) || ((i == 9) && (loadType == EphemerisType.MOON)) || ((i == 10) && (loadType == EphemerisType.SUN))) { firstIndex = row1; coeffs = row2; chunks = row3; } } // compute chunks duration final double timeSpan = extractDouble(record, HEADER_CHUNK_DURATION_OFFSET); ok = ok && (timeSpan > 0) && (timeSpan < 100); chunksDuration = Constants.JULIAN_DAY * (timeSpan / chunks); if (Double.isNaN(maxChunksDuration)) { maxChunksDuration = chunksDuration; } else { maxChunksDuration = FastMath.max(maxChunksDuration, chunksDuration); } // sanity checks if (!ok) { throw new OrekitException(OrekitMessages.NOT_A_JPL_EPHEMERIDES_BINARY_FILE, name); } }