List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D Vector3D
public Vector3D(double x, double y, double z)
From source file:org.orekit.files.ccsds.OPMParser.java
/** {@inheritDoc} */ public OPMFile parse(final InputStream stream, final String fileName) throws OrekitException { try {//from w w w . j a v a 2s . c om final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8")); // initialize internal data structures final ParseInfo pi = new ParseInfo(); pi.fileName = fileName; final OPMFile file = pi.file; // set the additional data that has been configured prior the parsing by the user. pi.file.setMissionReferenceDate(getMissionReferenceDate()); pi.file.setMuSet(getMu()); pi.file.setConventions(getConventions()); pi.file.getMetaData().setLaunchYear(getLaunchYear()); pi.file.getMetaData().setLaunchNumber(getLaunchNumber()); pi.file.getMetaData().setLaunchPiece(getLaunchPiece()); for (String line = reader.readLine(); line != null; line = reader.readLine()) { ++pi.lineNumber; if (line.trim().length() == 0) { continue; } pi.keyValue = new KeyValue(line, pi.lineNumber, pi.fileName); if (pi.keyValue.getKeyword() == null) { throw new OrekitException(OrekitMessages.CCSDS_UNEXPECTED_KEYWORD, pi.lineNumber, pi.fileName, line); } switch (pi.keyValue.getKeyword()) { case CCSDS_OPM_VERS: file.setFormatVersion(pi.keyValue.getDoubleValue()); break; case X: pi.x = pi.keyValue.getDoubleValue() * 1000; break; case Y: pi.y = pi.keyValue.getDoubleValue() * 1000; break; case Z: pi.z = pi.keyValue.getDoubleValue() * 1000; break; case X_DOT: pi.x_dot = pi.keyValue.getDoubleValue() * 1000; break; case Y_DOT: pi.y_dot = pi.keyValue.getDoubleValue() * 1000; break; case Z_DOT: pi.z_dot = pi.keyValue.getDoubleValue() * 1000; break; case MAN_EPOCH_IGNITION: if (pi.maneuver != null) { file.addManeuver(pi.maneuver); } pi.maneuver = new OPMFile.Maneuver(); pi.maneuver.setEpochIgnition(parseDate(pi.keyValue.getValue(), file.getTimeSystem())); if (!pi.commentTmp.isEmpty()) { pi.maneuver.setComment(pi.commentTmp); pi.commentTmp.clear(); } break; case MAN_DURATION: pi.maneuver.setDuration(pi.keyValue.getDoubleValue()); break; case MAN_DELTA_MASS: pi.maneuver.setDeltaMass(pi.keyValue.getDoubleValue()); break; case MAN_REF_FRAME: final CCSDSFrame manFrame = parseCCSDSFrame(pi.keyValue.getValue()); if (manFrame.isLof()) { pi.maneuver.setRefLofType(manFrame.getLofType()); } else { pi.maneuver.setRefFrame(manFrame.getFrame(getConventions(), isSimpleEOP())); } break; case MAN_DV_1: pi.maneuver.setdV(new Vector3D(pi.keyValue.getDoubleValue() * 1000, pi.maneuver.getDV().getY(), pi.maneuver.getDV().getZ())); break; case MAN_DV_2: pi.maneuver.setdV(new Vector3D(pi.maneuver.getDV().getX(), pi.keyValue.getDoubleValue() * 1000, pi.maneuver.getDV().getZ())); break; case MAN_DV_3: pi.maneuver.setdV(new Vector3D(pi.maneuver.getDV().getX(), pi.maneuver.getDV().getY(), pi.keyValue.getDoubleValue() * 1000)); break; default: boolean parsed = false; parsed = parsed || parseComment(pi.keyValue, pi.commentTmp); parsed = parsed || parseHeaderEntry(pi.keyValue, file, pi.commentTmp); parsed = parsed || parseMetaDataEntry(pi.keyValue, file.getMetaData(), pi.commentTmp); parsed = parsed || parseGeneralStateDataEntry(pi.keyValue, file, pi.commentTmp); if (!parsed) { throw new OrekitException(OrekitMessages.CCSDS_UNEXPECTED_KEYWORD, pi.lineNumber, pi.fileName, line); } } } file.setPosition(new Vector3D(pi.x, pi.y, pi.z)); file.setVelocity(new Vector3D(pi.x_dot, pi.y_dot, pi.z_dot)); if (pi.maneuver != null) { file.addManeuver(pi.maneuver); } reader.close(); return file; } catch (IOException ioe) { throw new OrekitException(ioe, new DummyLocalizable(ioe.getMessage())); } }
From source file:org.orekit.files.ccsds.OPMParserTest.java
@Test public void testParseOPM1() throws OrekitException { // simple test for OPM file, contains p/v entries and other mandatory // data./*from w w w . j a va 2 s. co m*/ final String ex = "/ccsds/OPMExample.txt"; final OPMParser parser = new OPMParser().withMu(398600e9).withConventions(IERSConventions.IERS_2010); final InputStream inEntry = getClass().getResourceAsStream(ex); final OPMFile file = parser.parse(inEntry, "OPMExample.txt"); final SatelliteTimeCoordinate coord = file.getSatelliteCoordinatesOPM(); // Check Header Block; Assert.assertEquals(2.0, file.getFormatVersion(), 1.0e-10); Assert.assertEquals(new AbsoluteDate(1998, 11, 06, 9, 23, 57, TimeScalesFactory.getUTC()), file.getCreationDate()); Assert.assertEquals("JAXA", file.getOriginator()); // Check Metadata Block; Assert.assertEquals("GODZILLA 5", file.getMetaData().getObjectName()); Assert.assertEquals("1998-057A", file.getMetaData().getObjectID()); Assert.assertEquals(1998, file.getMetaData().getLaunchYear()); Assert.assertEquals(57, file.getMetaData().getLaunchNumber()); Assert.assertEquals("A", file.getMetaData().getLaunchPiece()); Assert.assertEquals("EARTH", file.getMetaData().getCenterName()); Assert.assertTrue(file.getMetaData().getHasCreatableBody()); Assert.assertEquals(CelestialBodyFactory.getEarth(), file.getMetaData().getCenterBody()); Assert.assertEquals(CCSDSFrame.ITRF97.toString(), file.getMetaData().getFrame().getName()); Assert.assertEquals(TimeSystem.TAI, file.getTimeSystem()); // Check State Vector data Block; Assert.assertEquals(new AbsoluteDate(1998, 12, 18, 14, 28, 15.1172, TimeScalesFactory.getTAI()), coord.getEpoch()); checkPVEntry(new PVCoordinates(new Vector3D(6503514.000, 1239647.000, -717490.000), new Vector3D(-873.160, 8740.420, -4191.076)), coord.getCoordinate()); try { file.generateCartesianOrbit(); Assert.fail("an exception should have been thrown"); } catch (IllegalArgumentException iae) { // expected } try { file.generateKeplerianOrbit(); Assert.fail("an exception should have been thrown"); } catch (IllegalArgumentException iae) { // expected } try { file.generateSpacecraftState(); Assert.fail("an exception should have been thrown"); } catch (IllegalArgumentException iae) { // expected } }
From source file:org.orekit.files.ccsds.OPMParserTest.java
@Test public void testParseOPM2() throws OrekitException { // simple test for OPM file, contains all mandatory information plus // Keplerian elements, Spacecraft parameters and 2 maneuvers. final String ex = "/ccsds/OPMExample2.txt"; final OPMParser parser = new OPMParser(); final InputStream inEntry = getClass().getResourceAsStream(ex); final OPMFile file = parser.parse(inEntry, "OPMExample2.txt"); final SatelliteTimeCoordinate coord = file.getSatelliteCoordinatesOPM(); // Check Header Block; Assert.assertEquals(2.0, file.getFormatVersion(), 1.0e-10); ArrayList<String> headerComment = new ArrayList<String>(); headerComment.add("Generated by GSOC, R. Kiehling"); headerComment.add("Current intermediate orbit IO2 and maneuver planning data"); Assert.assertEquals(headerComment, file.getHeaderComment()); Assert.assertEquals(new AbsoluteDate(2000, 06, 03, 05, 33, 00, TimeScalesFactory.getUTC()), file.getCreationDate());/*from ww w. j a va 2s.c om*/ Assert.assertEquals(file.getOriginator(), "GSOC"); // Check Metadata Block; Assert.assertEquals("EUTELSAT W4", file.getMetaData().getObjectName()); Assert.assertEquals("2000-028A", file.getMetaData().getObjectID()); Assert.assertEquals("EARTH", file.getMetaData().getCenterName()); Assert.assertTrue(file.getMetaData().getHasCreatableBody()); Assert.assertEquals(CelestialBodyFactory.getEarth(), file.getMetaData().getCenterBody()); Assert.assertEquals(FramesFactory.getGCRF(), file.getMetaData().getFrame()); Assert.assertEquals(TimeSystem.GPS, file.getTimeSystem()); // Check Data State Vector block ArrayList<String> epochComment = new ArrayList<String>(); epochComment.add("State Vector"); Assert.assertEquals(epochComment, file.getEpochComment()); Assert.assertEquals(new AbsoluteDate(2006, 06, 03, 00, 00, 00, TimeScalesFactory.getGPS()), coord.getEpoch()); checkPVEntry(new PVCoordinates(new Vector3D(6655994.2, -40218575.1, -82917.7), new Vector3D(3115.48208, 470.42605, -1.01495)), coord.getCoordinate()); // Check Data Keplerian Elements block Assert.assertTrue(file.hasKeplerianElements()); ArrayList<String> keplerianElementsComment = new ArrayList<String>(); keplerianElementsComment.add("Keplerian elements"); Assert.assertEquals(keplerianElementsComment, file.getKeplerianElementsComment()); Assert.assertEquals(41399512.3, file.getA(), 1e-6); Assert.assertEquals(0.020842611, file.getE(), 1e-10); Assert.assertEquals(FastMath.toRadians(0.117746), file.getI(), 1e-10); Assert.assertEquals(FastMath.toRadians(17.604721), file.getRaan(), 1e-10); Assert.assertEquals(FastMath.toRadians(218.242943), file.getPa(), 1e-10); Assert.assertEquals(PositionAngle.TRUE, file.getAnomalyType()); Assert.assertEquals(FastMath.toRadians(41.922339), file.getAnomaly(), 1e-10); Assert.assertEquals(398600.4415 * 1e9, file.getMuParsed(), 1e-10); // Check Data Spacecraft block ArrayList<String> spacecraftComment = new ArrayList<String>(); spacecraftComment.add("Spacecraft parameters"); Assert.assertEquals(spacecraftComment, file.getSpacecraftComment()); Assert.assertEquals(1913.000, file.getMass(), 1e-10); Assert.assertEquals(10.000, file.getSolarRadArea(), 1e-10); Assert.assertEquals(1.300, file.getSolarRadCoeff(), 1e-10); Assert.assertEquals(10.000, file.getDragArea(), 1e-10); Assert.assertEquals(2.300, file.getDragCoeff(), 1e-10); // Check Data Maneuvers block Assert.assertTrue(file.getHasManeuver()); Assert.assertEquals(3, file.getNbManeuvers()); ArrayList<String> stateManeuverComment0 = new ArrayList<String>(); stateManeuverComment0.add("2 planned maneuvers"); stateManeuverComment0.add("First maneuver: AMF-3"); stateManeuverComment0.add("Non-impulsive, thrust direction fixed in inertial frame"); Assert.assertEquals(stateManeuverComment0, file.getManeuver(0).getComment()); Assert.assertEquals(new AbsoluteDate(2000, 06, 03, 9, 00, 34.1, TimeScalesFactory.getGPS()), file.getManeuvers().get(0).getEpochIgnition()); Assert.assertEquals(132.6, file.getManeuver(0).getDuration(), 1e-10); Assert.assertEquals(-18.418, file.getManeuver(0).getDeltaMass(), 1e-10); Assert.assertNull(file.getManeuver(0).getRefLofType()); Assert.assertEquals(FramesFactory.getEME2000(), file.getManeuver(0).getRefFrame()); Assert.assertEquals(0.0, new Vector3D(-23.25700, 16.83160, -8.93444).distance(file.getManeuver(0).getDV()), 1.0e-10); ArrayList<String> stateManeuverComment1 = new ArrayList<String>(); stateManeuverComment1.add("Second maneuver: first station acquisition maneuver"); stateManeuverComment1.add("impulsive, thrust direction fixed in RTN frame"); Assert.assertEquals(stateManeuverComment1, file.getManeuver(1).getComment()); Assert.assertEquals(new AbsoluteDate(2000, 06, 05, 18, 59, 21, TimeScalesFactory.getGPS()), file.getManeuvers().get(1).getEpochIgnition()); Assert.assertEquals(0.0, file.getManeuver(1).getDuration(), 1e-10); Assert.assertEquals(-1.469, file.getManeuver(1).getDeltaMass(), 1e-10); Assert.assertEquals(LOFType.QSW, file.getManeuver(1).getRefLofType()); Assert.assertNull(file.getManeuver(1).getRefFrame()); Assert.assertEquals(0.0, new Vector3D(1.015, -1.873, 0.0).distance(file.getManeuver(1).getDV()), 1.0e-10); Assert.assertTrue(file.getManeuver(2).getComment().isEmpty()); Assert.assertEquals(new AbsoluteDate(2000, 06, 05, 18, 59, 51, TimeScalesFactory.getGPS()), file.getManeuvers().get(2).getEpochIgnition()); Assert.assertEquals(0.0, file.getManeuver(2).getDuration(), 1e-10); Assert.assertEquals(-1.469, file.getManeuver(2).getDeltaMass(), 1e-10); Assert.assertEquals(LOFType.QSW, file.getManeuver(2).getRefLofType()); Assert.assertNull(file.getManeuver(2).getRefFrame()); Assert.assertEquals(0.0, new Vector3D(1.015, -1.873, 0.0).distance(file.getManeuver(2).getDV()), 1.0e-10); file.generateCartesianOrbit(); file.generateKeplerianOrbit(); file.generateSpacecraftState(); }
From source file:org.orekit.files.sp3.SP3Parser.java
/** Parses a single content line as read from the SP3 file. * @param line a string containing the line * @param pi the current {@link ParseInfo} object *///from w w w .ja va2 s .com private void parseContentLine(final String line, final ParseInfo pi) { // EP and EV lines are ignored so far final SP3File file = pi.file; switch (line.charAt(0)) { case '*': { final int year = Integer.parseInt(line.substring(3, 7).trim()); final int month = Integer.parseInt(line.substring(8, 10).trim()); final int day = Integer.parseInt(line.substring(11, 13).trim()); final int hour = Integer.parseInt(line.substring(14, 16).trim()); final int minute = Integer.parseInt(line.substring(17, 19).trim()); final double second = Double.parseDouble(line.substring(20, 31).trim()); pi.latestEpoch = new AbsoluteDate(year, month, day, hour, minute, second, pi.timeScale); break; } case 'P': { final String satelliteId = line.substring(1, 4).trim(); if (!file.containsSatellite(satelliteId)) { pi.latestPosition = null; } else { final double x = Double.parseDouble(line.substring(4, 18).trim()); final double y = Double.parseDouble(line.substring(18, 32).trim()); final double z = Double.parseDouble(line.substring(32, 46).trim()); // the position values are in km and have to be converted to m pi.latestPosition = new Vector3D(x * 1000, y * 1000, z * 1000); // clock (microsec) pi.latestClock = Double.parseDouble(line.substring(46, 60).trim()); // the additional items are optional and not read yet // if (line.length() >= 73) { // // x-sdev (b**n mm) // int xStdDevExp = Integer.valueOf(line.substring(61, // 63).trim()); // // y-sdev (b**n mm) // int yStdDevExp = Integer.valueOf(line.substring(64, // 66).trim()); // // z-sdev (b**n mm) // int zStdDevExp = Integer.valueOf(line.substring(67, // 69).trim()); // // c-sdev (b**n psec) // int cStdDevExp = Integer.valueOf(line.substring(70, // 73).trim()); // // pi.posStdDevRecord = // new PositionStdDevRecord(Math.pow(pi.posVelBase, xStdDevExp), // Math.pow(pi.posVelBase, // yStdDevExp), Math.pow(pi.posVelBase, zStdDevExp), // Math.pow(pi.clockBase, cStdDevExp)); // // String clockEventFlag = line.substring(74, 75); // String clockPredFlag = line.substring(75, 76); // String maneuverFlag = line.substring(78, 79); // String orbitPredFlag = line.substring(79, 80); // } if (!pi.hasVelocityEntries) { final SatelliteTimeCoordinate coord = new SatelliteTimeCoordinate(pi.latestEpoch, pi.latestPosition, pi.latestClock); file.addSatelliteCoordinate(satelliteId, coord); } } break; } case 'V': { final String satelliteId = line.substring(1, 4).trim(); if (file.containsSatellite(satelliteId)) { final double xv = Double.parseDouble(line.substring(4, 18).trim()); final double yv = Double.parseDouble(line.substring(18, 32).trim()); final double zv = Double.parseDouble(line.substring(32, 46).trim()); // the velocity values are in dm/s and have to be converted to m/s final Vector3D velocity = new Vector3D(xv / 10d, yv / 10d, zv / 10d); final double clockRateChange = Double.parseDouble(line.substring(46, 60).trim()); // the additional items are optional and not read yet // if (line.length() >= 73) { // // xvel-sdev (b**n 10**-4 mm/sec) // int xVstdDevExp = Integer.valueOf(line.substring(61, // 63).trim()); // // yvel-sdev (b**n 10**-4 mm/sec) // int yVstdDevExp = Integer.valueOf(line.substring(64, // 66).trim()); // // zvel-sdev (b**n 10**-4 mm/sec) // int zVstdDevExp = Integer.valueOf(line.substring(67, // 69).trim()); // // clkrate-sdev (b**n 10**-4 psec/sec) // int clkStdDevExp = Integer.valueOf(line.substring(70, // 73).trim()); // } final SatelliteTimeCoordinate coord = new SatelliteTimeCoordinate(pi.latestEpoch, new PVCoordinates(pi.latestPosition, velocity), pi.latestClock, clockRateChange); file.addSatelliteCoordinate(satelliteId, coord); } break; } default: // ignore everything else break; } }
From source file:org.orekit.files.sp3.SP3ParserTest.java
@Test public void testParseSP3a1() throws OrekitException { // simple test for version sp3-a, only contains position entries final String ex = "/sp3/sp3_a_example1.txt"; final SP3Parser parser = new SP3Parser(); final InputStream inEntry = getClass().getResourceAsStream(ex); final SP3File file = parser.parse(inEntry); Assert.assertEquals(SP3OrbitType.FIT, file.getOrbitType()); Assert.assertEquals(TimeSystem.GPS, file.getTimeSystem()); Assert.assertEquals(25, file.getSatelliteCount()); final List<SatelliteTimeCoordinate> coords = file.getSatelliteCoordinates("1"); Assert.assertEquals(3, coords.size()); final SatelliteTimeCoordinate coord = coords.get(0); // 1994 12 17 0 0 0.00000000 Assert.assertEquals(new AbsoluteDate(1994, 12, 17, 0, 0, 0, TimeScalesFactory.getGPS()), coord.getEpoch()); // P 1 16258.524750 -3529.015750 -20611.427050 -62.540600 checkPVEntry(/*from w w w.j a v a 2s .c om*/ new PVCoordinates(new Vector3D(16258524.75, -3529015.75, -20611427.049), new Vector3D(0, 0, 0)), coord.getCoordinate()); }
From source file:org.orekit.files.sp3.SP3ParserTest.java
@Test public void testParseSP3a2() throws OrekitException { // simple test for version sp3-a, contains p/v entries final String ex = "/sp3/sp3_a_example2.txt"; final SP3Parser parser = new SP3Parser(); final InputStream inEntry = getClass().getResourceAsStream(ex); final SP3File file = parser.parse(inEntry); Assert.assertEquals(SP3OrbitType.FIT, file.getOrbitType()); Assert.assertEquals(TimeSystem.GPS, file.getTimeSystem()); Assert.assertEquals(25, file.getSatelliteCount()); final List<SatelliteTimeCoordinate> coords = file.getSatelliteCoordinates("1"); Assert.assertEquals(3, coords.size()); final SatelliteTimeCoordinate coord = coords.get(0); // 1994 12 17 0 0 0.00000000 Assert.assertEquals(new AbsoluteDate(1994, 12, 17, 0, 0, 0, TimeScalesFactory.getGPS()), coord.getEpoch()); // P 1 16258.524750 -3529.015750 -20611.427050 -62.540600 // V 1 -6560.373522 25605.954994 -9460.427179 -0.024236 checkPVEntry(new PVCoordinates(new Vector3D(16258524.75, -3529015.75, -20611427.049), new Vector3D(-656.0373, 2560.5954, -946.0427)), coord.getCoordinate()); }
From source file:org.orekit.files.sp3.SP3ParserTest.java
@Test public void testParseSP3c1() throws OrekitException { // simple test for version sp3-c, contains p/v entries final String ex = "/sp3/sp3_c_example1.txt"; final SP3Parser parser = new SP3Parser(); final InputStream inEntry = getClass().getResourceAsStream(ex); final SP3File file = parser.parse(inEntry); Assert.assertEquals(SP3OrbitType.HLM, file.getOrbitType()); Assert.assertEquals(TimeSystem.GPS, file.getTimeSystem()); Assert.assertEquals(26, file.getSatelliteCount()); final List<SatelliteTimeCoordinate> coords = file.getSatelliteCoordinates("G01"); Assert.assertEquals(2, coords.size()); final SatelliteTimeCoordinate coord = coords.get(0); // 2001 8 8 0 0 0.00000000 Assert.assertEquals(new AbsoluteDate(2001, 8, 8, 0, 0, 0, TimeScalesFactory.getGPS()), coord.getEpoch()); // PG01 -11044.805800 -10475.672350 21929.418200 189.163300 18 18 18 219 checkPVEntry(new PVCoordinates(new Vector3D(-11044805.8, -10475672.35, 21929418.2), new Vector3D(0, 0, 0)), coord.getCoordinate());/*from ww w . j a va 2 s. co m*/ }
From source file:org.orekit.forces.AbstractForceModelTest.java
protected void checkParameterDerivative(SpacecraftState state, ForceModel forceModel, String name, double hFactor, double tol) throws OrekitException { try {//from w w w. j a v a 2 s .com forceModel.accelerationDerivatives(state, "not a parameter"); Assert.fail("an exception should have been thrown"); } catch (UnknownParameterException upe) { // expected } catch (OrekitException oe) { // expected Assert.assertEquals(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, oe.getSpecifier()); } FieldVector3D<DerivativeStructure> accDer = forceModel.accelerationDerivatives(state, name); Vector3D derivative = new Vector3D(accDer.getX().getPartialDerivative(1), accDer.getY().getPartialDerivative(1), accDer.getZ().getPartialDerivative(1)); AccelerationRetriever accelerationRetriever = new AccelerationRetriever(); double p0 = forceModel.getParameter(name); double hParam = hFactor * forceModel.getParameter(name); forceModel.setParameter(name, p0 - 1 * hParam); Assert.assertEquals(p0 - 1 * hParam, forceModel.getParameter(name), 1.0e-10); forceModel.addContribution(state, accelerationRetriever); final Vector3D gammaM1h = accelerationRetriever.getAcceleration(); forceModel.setParameter(name, p0 + 1 * hParam); Assert.assertEquals(p0 + 1 * hParam, forceModel.getParameter(name), 1.0e-10); forceModel.addContribution(state, accelerationRetriever); final Vector3D gammaP1h = accelerationRetriever.getAcceleration(); final Vector3D reference = new Vector3D(1 / (2 * hParam), gammaP1h.subtract(gammaM1h)); final Vector3D delta = derivative.subtract(reference); Assert.assertEquals(0, delta.getNorm(), tol * reference.getNorm()); }
From source file:org.orekit.forces.BoxAndSolarArraySpacecraftTest.java
@Test public void testCorrectFixedRate() throws OrekitException { AbsoluteDate initialDate = propagator.getInitialState().getDate(); CelestialBody sun = CelestialBodyFactory.getSun(); BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(1.5, 3.5, 2.5, sun, 20.0, Vector3D.PLUS_J, initialDate, new Vector3D(0.46565509814462996, 0.0, 0.884966287251619), propagator.getInitialState().getKeplerianMeanMotion(), 0.0, 0.0, 0.0); for (double dt = 0; dt < 4000; dt += 60) { SpacecraftState state = propagator.propagate(initialDate.shiftedBy(dt)); Vector3D sunInert = sun.getPVCoordinates(initialDate, state.getFrame()).getPosition(); Vector3D momentum = state.getPVCoordinates().getMomentum(); double sunElevation = FastMath.PI / 2 - Vector3D.angle(sunInert, momentum); Assert.assertEquals(15.1, FastMath.toDegrees(sunElevation), 0.1); Vector3D n = s.getNormal(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation()); Assert.assertEquals(0.0, n.getY(), 1.0e-10); // normal misalignment should be entirely due to sun being out of orbital plane Vector3D sunSat = state.getAttitude().getRotation().applyTo(sunInert); double misAlignment = Vector3D.angle(sunSat, n); Assert.assertEquals(sunElevation, misAlignment, 1.0e-3); }//from w w w.j a v a2 s . c o m }
From source file:org.orekit.forces.BoxAndSolarArraySpacecraftTest.java
@Test public void testTooSlowFixedRate() throws OrekitException { AbsoluteDate initialDate = propagator.getInitialState().getDate(); CelestialBody sun = CelestialBodyFactory.getSun(); BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(1.5, 3.5, 2.5, sun, 20.0, Vector3D.PLUS_J, initialDate, new Vector3D(0.46565509814462996, 0.0, 0.884966287251619), 0.1 * propagator.getInitialState().getKeplerianMeanMotion(), 0.0, 0.0, 0.0); double maxDelta = 0; for (double dt = 0; dt < 4000; dt += 60) { SpacecraftState state = propagator.propagate(initialDate.shiftedBy(dt)); Vector3D sunInert = sun.getPVCoordinates(initialDate, state.getFrame()).getPosition(); Vector3D momentum = state.getPVCoordinates().getMomentum(); double sunElevation = FastMath.PI / 2 - Vector3D.angle(sunInert, momentum); Assert.assertEquals(15.1, FastMath.toDegrees(sunElevation), 0.1); Vector3D n = s.getNormal(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation()); Assert.assertEquals(0.0, n.getY(), 1.0e-10); // normal misalignment should become very large as solar array rotation is plain wrong Vector3D sunSat = state.getAttitude().getRotation().applyTo(sunInert); double misAlignment = Vector3D.angle(sunSat, n); maxDelta = FastMath.max(maxDelta, FastMath.abs(sunElevation - misAlignment)); }/*from ww w . j av a2 s .c om*/ Assert.assertTrue(FastMath.toDegrees(maxDelta) > 120.0); }