Search in sources :

Example 71 with Transform

use of org.orekit.frames.Transform in project Orekit by CS-SI.

the class EcksteinHechlerPropagatorTest method testIssue224Forward.

@Test
public void testIssue224Forward() throws OrekitException, IOException, ClassNotFoundException {
    AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(154.);
    Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    Frame eme2000 = FramesFactory.getEME2000();
    Vector3D pole = itrf.getTransformTo(eme2000, date).transformVector(Vector3D.PLUS_K);
    Frame poleAligned = new Frame(FramesFactory.getEME2000(), new Transform(date, new Rotation(pole, Vector3D.PLUS_K)), "pole aligned", true);
    CircularOrbit initial = new CircularOrbit(7208669.8179538045, 1.3740461966386876E-4, -3.2364250248363356E-5, FastMath.toRadians(97.40236024565775), FastMath.toRadians(166.15873160992115), FastMath.toRadians(90.1282370098961), PositionAngle.MEAN, poleAligned, date, provider.getMu());
    EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(initial, new LofOffset(poleAligned, LOFType.VVLH), 1000.0, provider);
    propagator.addAdditionalStateProvider(new SevenProvider());
    propagator.setEphemerisMode();
    // Impulsive burns
    final AbsoluteDate burn1Date = initial.getDate().shiftedBy(200);
    ImpulseManeuver<DateDetector> impulsiveBurn1 = new ImpulseManeuver<DateDetector>(new DateDetector(burn1Date), new Vector3D(0.0, 500.0, 0.0), 320);
    propagator.addEventDetector(impulsiveBurn1);
    final AbsoluteDate burn2Date = initial.getDate().shiftedBy(300);
    ImpulseManeuver<DateDetector> impulsiveBurn2 = new ImpulseManeuver<DateDetector>(new DateDetector(burn2Date), new Vector3D(0.0, 500.0, 0.0), 320);
    propagator.addEventDetector(impulsiveBurn2);
    propagator.propagate(initial.getDate().shiftedBy(400));
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(propagator.getGeneratedEphemeris());
    Assert.assertTrue(bos.size() > 2950);
    Assert.assertTrue(bos.size() < 3050);
    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bis);
    BoundedPropagator ephemeris = (BoundedPropagator) ois.readObject();
    ephemeris.setMasterMode(10, new OrekitFixedStepHandler() {

        public void handleStep(SpacecraftState currentState, boolean isLast) {
            if (currentState.getDate().durationFrom(burn1Date) < -0.001) {
                Assert.assertEquals(97.402, FastMath.toDegrees(currentState.getI()), 1.0e-3);
            } else if (currentState.getDate().durationFrom(burn1Date) > 0.001 && currentState.getDate().durationFrom(burn2Date) < -0.001) {
                Assert.assertEquals(98.183, FastMath.toDegrees(currentState.getI()), 1.0e-3);
            } else if (currentState.getDate().durationFrom(burn2Date) > 0.001) {
                Assert.assertEquals(99.310, FastMath.toDegrees(currentState.getI()), 1.0e-3);
            }
        }
    });
    ephemeris.propagate(ephemeris.getMaxDate());
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) ImpulseManeuver(org.orekit.forces.maneuvers.ImpulseManeuver) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) ByteArrayInputStream(java.io.ByteArrayInputStream) Transform(org.orekit.frames.Transform) LofOffset(org.orekit.attitudes.LofOffset) BoundedPropagator(org.orekit.propagation.BoundedPropagator) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 72 with Transform

use of org.orekit.frames.Transform in project Orekit by CS-SI.

the class SpacecraftStateTest method testTransform.

@Test
public void testTransform() throws ParseException, OrekitException {
    double maxDP = 0;
    double maxDV = 0;
    double maxDA = 0;
    for (double t = 0; t < orbit.getKeplerianPeriod(); t += 60) {
        final SpacecraftState state = propagator.propagate(orbit.getDate().shiftedBy(t));
        final Transform transform = state.toTransform().getInverse();
        PVCoordinates pv = transform.transformPVCoordinates(PVCoordinates.ZERO);
        PVCoordinates dPV = new PVCoordinates(pv, state.getPVCoordinates());
        Vector3D mZDirection = transform.transformVector(Vector3D.MINUS_K);
        double alpha = Vector3D.angle(mZDirection, state.getPVCoordinates().getPosition());
        maxDP = FastMath.max(maxDP, dPV.getPosition().getNorm());
        maxDV = FastMath.max(maxDV, dPV.getVelocity().getNorm());
        maxDA = FastMath.max(maxDA, FastMath.toDegrees(alpha));
    }
    Assert.assertEquals(0.0, maxDP, 1.0e-6);
    Assert.assertEquals(0.0, maxDV, 1.0e-9);
    Assert.assertEquals(0.0, maxDA, 1.0e-12);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) PVCoordinates(org.orekit.utils.PVCoordinates) Transform(org.orekit.frames.Transform) Test(org.junit.Test)

Example 73 with Transform

use of org.orekit.frames.Transform in project Orekit by CS-SI.

the class GeoidTest method testGetIntersectionPointFrame.

/**
 * check {@link Geoid#getIntersectionPoint(Line, Vector3D, Frame,
 * AbsoluteDate)} handles frame transformations correctly
 *
 * @throws OrekitException on error
 */
@Test
public void testGetIntersectionPointFrame() throws OrekitException {
    // setup
    Geoid geoid = getComponent();
    Frame frame = new Frame(geoid.getBodyFrame(), new Transform(date, new Transform(date, new Vector3D(-1, 2, -3), new Vector3D(4, -5, 6)), new Transform(date, new Rotation(-7, 8, -9, 10, true), new Vector3D(-11, 12, -13))), "test frame");
    GeodeticPoint gp = new GeodeticPoint(FastMath.toRadians(46.8743190), FastMath.toRadians(102.4487290), 0);
    Vector3D expected = geoid.transform(gp);
    // glancing line: 10% vertical and 90% north (~6 deg elevation)
    Vector3D slope = gp.getZenith().scalarMultiply(0.1).add(gp.getNorth().scalarMultiply(0.9));
    Vector3D close = expected.add(slope.scalarMultiply(100));
    Line line = new Line(expected.add(slope), close, 0);
    Transform xform = geoid.getBodyFrame().getTransformTo(frame, date);
    // transform to test frame
    close = xform.transformPosition(close);
    line = xform.transformLine(line);
    // action
    GeodeticPoint actual = geoid.getIntersectionPoint(line, close, frame, date);
    // verify, 1 um position accuracy at Earth's surface
    assertThat(actual, geodeticPointCloseTo(gp, 1e-6));
}
Also used : Line(org.hipparchus.geometry.euclidean.threed.Line) Frame(org.orekit.frames.Frame) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Transform(org.orekit.frames.Transform) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) Test(org.junit.Test)

Example 74 with Transform

use of org.orekit.frames.Transform in project Orekit by CS-SI.

the class Frames3 method main.

public static void main(String[] args) {
    try {
        // configure Orekit
        File home = new File(System.getProperty("user.home"));
        File orekitData = new File(home, "orekit-data");
        if (!orekitData.exists()) {
            System.err.format(Locale.US, "Failed to find %s folder%n", orekitData.getAbsolutePath());
            System.err.format(Locale.US, "You need to download %s from the %s page and unzip it in %s for this tutorial to work%n", "orekit-data.zip", "https://www.orekit.org/forge/projects/orekit/files", home.getAbsolutePath());
            System.exit(1);
        }
        DataProvidersManager manager = DataProvidersManager.getInstance();
        manager.addProvider(new DirectoryCrawler(orekitData));
        // Initial state definition :
        // ==========================
        // Date
        // ****
        AbsoluteDate initialDate = new AbsoluteDate(2003, 4, 7, 10, 55, 21.575, TimeScalesFactory.getUTC());
        // Orbit
        // *****
        // The Sun is in the orbital plane for raan ~ 202
        // gravitation coefficient
        double mu = 3.986004415e+14;
        // inertial frame
        Frame eme2000 = FramesFactory.getEME2000();
        Orbit orbit = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.), FastMath.toRadians(220.), FastMath.toRadians(5.300), PositionAngle.MEAN, eme2000, initialDate, mu);
        // Attitude laws
        // *************
        // Earth
        Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
        BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, earthFrame);
        // Target pointing attitude provider over satellite nadir at date, without yaw compensation
        NadirPointing nadirLaw = new NadirPointing(eme2000, earth);
        // Target pointing attitude provider with yaw compensation
        final PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
        YawSteering yawSteeringLaw = new YawSteering(eme2000, nadirLaw, sun, Vector3D.MINUS_I);
        // Propagator : Eckstein-Hechler analytic propagator
        Propagator propagator = new EcksteinHechlerPropagator(orbit, yawSteeringLaw, Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);
        // Let's write the results in a file in order to draw some plots.
        propagator.setMasterMode(10, new OrekitFixedStepHandler() {

            PrintStream out = null;

            public void init(SpacecraftState s0, AbsoluteDate t, double step) throws OrekitException {
                try {
                    File file = new File(System.getProperty("user.home"), "XYZ.dat");
                    System.out.println("Results written to file: " + file.getAbsolutePath());
                    out = new PrintStream(file, "UTF-8");
                    out.println("#time X Y Z Wx Wy Wz");
                } catch (IOException ioe) {
                    throw new OrekitException(ioe, LocalizedCoreFormats.SIMPLE_MESSAGE, ioe.getLocalizedMessage());
                }
            }

            public void handleStep(SpacecraftState currentState, boolean isLast) throws OrekitException {
                // get the transform from orbit/attitude reference frame to spacecraft frame
                Transform inertToSpacecraft = currentState.toTransform();
                // get the position of the Sun in orbit/attitude reference frame
                Vector3D sunInert = sun.getPVCoordinates(currentState.getDate(), currentState.getFrame()).getPosition();
                // convert Sun position to spacecraft frame
                Vector3D sunSat = inertToSpacecraft.transformPosition(sunInert);
                // and the spacecraft rotational rate also
                Vector3D spin = inertToSpacecraft.getRotationRate();
                // Lets calculate the reduced coordinates
                double sunX = sunSat.getX() / sunSat.getNorm();
                double sunY = sunSat.getY() / sunSat.getNorm();
                double sunZ = sunSat.getZ() / sunSat.getNorm();
                out.format(Locale.US, "%s %12.3f %12.3f %12.3f %12.7f %12.7f %12.7f%n", currentState.getDate(), sunX, sunY, sunZ, spin.getX(), spin.getY(), spin.getZ());
                if (isLast) {
                    out.close();
                }
            }
        });
        System.out.println("Running...");
        propagator.propagate(initialDate.shiftedBy(6000));
    } catch (OrekitException oe) {
        System.err.println(oe.getMessage());
    }
}
Also used : NadirPointing(org.orekit.attitudes.NadirPointing) PrintStream(java.io.PrintStream) Frame(org.orekit.frames.Frame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) IOException(java.io.IOException) BodyShape(org.orekit.bodies.BodyShape) AbsoluteDate(org.orekit.time.AbsoluteDate) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Propagator(org.orekit.propagation.Propagator) DirectoryCrawler(org.orekit.data.DirectoryCrawler) YawSteering(org.orekit.attitudes.YawSteering) DataProvidersManager(org.orekit.data.DataProvidersManager) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) OrekitException(org.orekit.errors.OrekitException) Transform(org.orekit.frames.Transform) File(java.io.File) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler)

Example 75 with Transform

use of org.orekit.frames.Transform in project Orekit by CS-SI.

the class Frames2 method main.

public static void main(String[] args) {
    try {
        // configure Orekit
        File home = new File(System.getProperty("user.home"));
        File orekitData = new File(home, "orekit-data");
        if (!orekitData.exists()) {
            System.err.format(Locale.US, "Failed to find %s folder%n", orekitData.getAbsolutePath());
            System.err.format(Locale.US, "You need to download %s from the %s page and unzip it in %s for this tutorial to work%n", "orekit-data.zip", "https://www.orekit.org/forge/projects/orekit/files", home.getAbsolutePath());
            System.exit(1);
        }
        DataProvidersManager manager = DataProvidersManager.getInstance();
        manager.addProvider(new DirectoryCrawler(orekitData));
        // Considering the following Computing/Measurement date in UTC time scale
        TimeScale utc = TimeScalesFactory.getUTC();
        AbsoluteDate date = new AbsoluteDate(2008, 10, 01, 12, 00, 00.000, utc);
        // The Center of Gravity frame has its origin at the satellite center of gravity (CoG)
        // and its axes parallel to EME2000. It is derived from EME2000 frame at any moment
        // by an unknown transform which depends on the current position and the velocity.
        // Let's initialize this transform by the identity transform.
        UpdatableFrame cogFrame = new UpdatableFrame(FramesFactory.getEME2000(), Transform.IDENTITY, "LOF", false);
        // The satellite frame, with origin also at the CoG, depends on attitude.
        // For the sake of this tutorial, we consider a simple inertial attitude here
        Transform cogToSat = new Transform(date, new Rotation(0.6, 0.48, 0, 0.64, false));
        Frame satFrame = new Frame(cogFrame, cogToSat, "sat", false);
        // Finally, the GPS antenna frame can be defined from the satellite frame by 2 transforms:
        // a translation and a rotation
        Transform translateGPS = new Transform(date, new Vector3D(0, 0, 1));
        Transform rotateGPS = new Transform(date, new Rotation(new Vector3D(0, 1, 3), FastMath.toRadians(10), RotationConvention.VECTOR_OPERATOR));
        Frame gpsFrame = new Frame(satFrame, new Transform(date, translateGPS, rotateGPS), "GPS", false);
        // Let's get the satellite position and velocity in ITRF as measured by GPS antenna at this moment:
        final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
        final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
        System.out.format(Locale.US, "GPS antenna position in ITRF:    %12.3f %12.3f %12.3f%n", position.getX(), position.getY(), position.getZ());
        System.out.format(Locale.US, "GPS antenna velocity in ITRF:    %12.7f %12.7f %12.7f%n", velocity.getX(), velocity.getY(), velocity.getZ());
        // The transform from GPS frame to ITRF frame at this moment is defined by
        // a translation and a rotation. The translation is directly provided by the
        // GPS measurement above. The rotation is extracted from the existing tree, where
        // we know all rotations are already up to date, even if one translation is still
        // unknown. We combine the extracted rotation and the measured translation by
        // applying the rotation first because the position/velocity vector are given in
        // ITRF frame not in GPS antenna frame:
        Transform measuredTranslation = new Transform(date, position, velocity);
        Transform formerTransform = gpsFrame.getTransformTo(FramesFactory.getITRF(IERSConventions.IERS_2010, true), date);
        Transform preservedRotation = new Transform(date, formerTransform.getRotation(), formerTransform.getRotationRate());
        Transform gpsToItrf = new Transform(date, preservedRotation, measuredTranslation);
        // So we can update the transform from EME2000 to CoG frame
        cogFrame.updateTransform(gpsFrame, FramesFactory.getITRF(IERSConventions.IERS_2010, true), gpsToItrf, date);
        // And we can get the position and velocity of satellite CoG in EME2000 frame
        PVCoordinates origin = PVCoordinates.ZERO;
        Transform cogToItrf = cogFrame.getTransformTo(FramesFactory.getITRF(IERSConventions.IERS_2010, true), date);
        PVCoordinates satItrf = cogToItrf.transformPVCoordinates(origin);
        System.out.format(Locale.US, "Satellite   position in ITRF:    %12.3f %12.3f %12.3f%n", satItrf.getPosition().getX(), satItrf.getPosition().getY(), satItrf.getPosition().getZ());
        System.out.format(Locale.US, "Satellite   velocity in ITRF:    %12.7f %12.7f %12.7f%n", satItrf.getVelocity().getX(), satItrf.getVelocity().getY(), satItrf.getVelocity().getZ());
        Transform cogToEme2000 = cogFrame.getTransformTo(FramesFactory.getEME2000(), date);
        PVCoordinates satEME2000 = cogToEme2000.transformPVCoordinates(origin);
        System.out.format(Locale.US, "Satellite   position in EME2000: %12.3f %12.3f %12.3f%n", satEME2000.getPosition().getX(), satEME2000.getPosition().getY(), satEME2000.getPosition().getZ());
        System.out.format(Locale.US, "Satellite   velocity in EME2000: %12.7f %12.7f %12.7f%n", satEME2000.getVelocity().getX(), satEME2000.getVelocity().getY(), satEME2000.getVelocity().getZ());
    } catch (OrekitException oe) {
        System.err.println(oe.getMessage());
    }
}
Also used : UpdatableFrame(org.orekit.frames.UpdatableFrame) Frame(org.orekit.frames.Frame) UpdatableFrame(org.orekit.frames.UpdatableFrame) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) DirectoryCrawler(org.orekit.data.DirectoryCrawler) DataProvidersManager(org.orekit.data.DataProvidersManager) PVCoordinates(org.orekit.utils.PVCoordinates) OrekitException(org.orekit.errors.OrekitException) Transform(org.orekit.frames.Transform) File(java.io.File) TimeScale(org.orekit.time.TimeScale) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) AbsoluteDate(org.orekit.time.AbsoluteDate)

Aggregations

Transform (org.orekit.frames.Transform)75 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)56 AbsoluteDate (org.orekit.time.AbsoluteDate)33 Frame (org.orekit.frames.Frame)28 FieldTransform (org.orekit.frames.FieldTransform)26 SpacecraftState (org.orekit.propagation.SpacecraftState)26 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)25 PVCoordinates (org.orekit.utils.PVCoordinates)23 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)21 Test (org.junit.Test)20 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)18 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)17 GeodeticPoint (org.orekit.bodies.GeodeticPoint)13 TopocentricFrame (org.orekit.frames.TopocentricFrame)12 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)11 OrekitException (org.orekit.errors.OrekitException)11 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)10 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)10 FieldRotation (org.hipparchus.geometry.euclidean.threed.FieldRotation)8 CircularOrbit (org.orekit.orbits.CircularOrbit)8