List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Rotation getAngle
public double getAngle()
From source file:org.orekit.attitudes.InertialAttitudeTest.java
@Test public void testIsInertial() throws OrekitException { InertialProvider law = new InertialProvider(new Rotation(new Vector3D(0.6, 0.48, 0.64), 0.9)); KeplerianPropagator propagator = new KeplerianPropagator(orbit0, law); Attitude initial = propagator.propagate(t0).getAttitude(); for (double t = 0; t < 10000.0; t += 100) { Attitude attitude = propagator.propagate(t0.shiftedBy(t)).getAttitude(); Rotation evolution = attitude.getRotation().applyTo(initial.getRotation().revert()); Assert.assertEquals(0, evolution.getAngle(), 1.0e-10); Assert.assertEquals(FramesFactory.getEME2000(), attitude.getReferenceFrame()); }/*w w w. j a va 2 s. c om*/ }
From source file:org.orekit.attitudes.InertialAttitudeTest.java
@Test public void testCompensateMomentum() throws OrekitException { InertialProvider law = new InertialProvider(new Rotation(new Vector3D(-0.64, 0.6, 0.48), 0.2)); KeplerianPropagator propagator = new KeplerianPropagator(orbit0, law); Attitude initial = propagator.propagate(t0).getAttitude(); for (double t = 0; t < 10000.0; t += 100) { Attitude attitude = propagator.propagate(t0.shiftedBy(t)).getAttitude(); Rotation evolution = attitude.getRotation().applyTo(initial.getRotation().revert()); Assert.assertEquals(0, evolution.getAngle(), 1.0e-10); Assert.assertEquals(FramesFactory.getEME2000(), attitude.getReferenceFrame()); }//from w ww . j a va2s . com }
From source file:org.orekit.attitudes.InertialAttitudeTest.java
@Test public void testSpin() throws OrekitException { AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC()); AttitudeProvider law = new InertialProvider(new Rotation(new Vector3D(-0.64, 0.6, 0.48), 0.2)); KeplerianOrbit orbit = new KeplerianOrbit(7178000.0, 1.e-4, FastMath.toRadians(50.), FastMath.toRadians(10.), FastMath.toRadians(20.), FastMath.toRadians(30.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, 3.986004415e14); Propagator propagator = new KeplerianPropagator(orbit, law); double h = 100.0; SpacecraftState sMinus = propagator.propagate(date.shiftedBy(-h)); SpacecraftState s0 = propagator.propagate(date); SpacecraftState sPlus = propagator.propagate(date.shiftedBy(h)); // check spin is consistent with attitude evolution double errorAngleMinus = Rotation.distance(sMinus.shiftedBy(h).getAttitude().getRotation(), s0.getAttitude().getRotation()); double evolutionAngleMinus = Rotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation()); Assert.assertEquals(0.0, errorAngleMinus, 1.0e-6 * evolutionAngleMinus); double errorAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.shiftedBy(-h).getAttitude().getRotation()); double evolutionAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation()); Assert.assertEquals(0.0, errorAnglePlus, 1.0e-6 * evolutionAnglePlus); // compute spin axis using finite differences Rotation rMinus = sMinus.getAttitude().getRotation(); Rotation rPlus = sPlus.getAttitude().getRotation(); Rotation dr = rPlus.applyTo(rMinus.revert()); Assert.assertEquals(0, dr.getAngle(), 1.0e-10); Vector3D spin0 = s0.getAttitude().getSpin(); Assert.assertEquals(0, spin0.getNorm(), 1.0e-10); }
From source file:org.orekit.attitudes.NadirPointingTest.java
/** Test in the case of a spheric earth : nadir pointing shall be * the same as earth center pointing/* w ww . j a v a 2s.c o m*/ */ @Test public void testSphericEarth() throws OrekitException { // Spheric earth shape OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 0., itrf); // Create nadir pointing attitude provider NadirPointing nadirAttitudeLaw = new NadirPointing(FramesFactory.getEME2000(), earthShape); // Create earth center pointing attitude provider BodyCenterPointing earthCenterAttitudeLaw = new BodyCenterPointing(FramesFactory.getEME2000(), earthShape); // Create satellite position as circular parameters CircularOrbit circ = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.), FastMath.toRadians(270.), FastMath.toRadians(5.300), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); // Get nadir attitude Rotation rotNadir = nadirAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation(); // Get earth center attitude Rotation rotCenter = earthCenterAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation(); // For a spheric earth, earth center pointing attitude and nadir pointing attitude // shall be the same, i.e the composition of inverse earth pointing rotation // with nadir pointing rotation shall be identity. Rotation rotCompo = rotCenter.applyInverseTo(rotNadir); double angle = rotCompo.getAngle(); Assert.assertEquals(angle, 0.0, Utils.epsilonAngle); }
From source file:org.orekit.attitudes.NadirPointingTest.java
/** Test in the case of an elliptic earth : nadir pointing shall be : * - the same as earth center pointing in case of equatorial or polar position * - different from earth center pointing in any other case *///from ww w . j a v a 2 s . c o m @Test public void testNonSphericEarth() throws OrekitException { // Elliptic earth shape OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, itrf); // Create nadir pointing attitude provider NadirPointing nadirAttitudeLaw = new NadirPointing(FramesFactory.getEME2000(), earthShape); // Create earth center pointing attitude provider BodyCenterPointing earthCenterAttitudeLaw = new BodyCenterPointing(FramesFactory.getEME2000(), earthShape); // Satellite on equatorial position // ********************************** KeplerianOrbit kep = new KeplerianOrbit(7178000.0, 1.e-8, FastMath.toRadians(50.), 0., 0., 0., PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu); // Get nadir attitude Rotation rotNadir = nadirAttitudeLaw.getAttitude(kep, date, kep.getFrame()).getRotation(); // Get earth center attitude Rotation rotCenter = earthCenterAttitudeLaw.getAttitude(kep, date, kep.getFrame()).getRotation(); // For a satellite at equatorial position, earth center pointing attitude and nadir pointing // attitude shall be the same, i.e the composition of inverse earth pointing rotation // with nadir pointing rotation shall be identity. Rotation rotCompo = rotCenter.applyInverseTo(rotNadir); double angle = rotCompo.getAngle(); Assert.assertEquals(0.0, angle, 5.e-6); // Satellite on polar position // ***************************** CircularOrbit circ = new CircularOrbit(7178000.0, 1.e-5, 0., FastMath.toRadians(90.), 0., FastMath.toRadians(90.), PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu); // Get nadir attitude rotNadir = nadirAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation(); // Get earth center attitude rotCenter = earthCenterAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation(); // For a satellite at polar position, earth center pointing attitude and nadir pointing // attitude shall be the same, i.e the composition of inverse earth pointing rotation // with nadir pointing rotation shall be identity. rotCompo = rotCenter.applyInverseTo(rotNadir); angle = rotCompo.getAngle(); Assert.assertEquals(angle, 0.0, 5.e-6); // Satellite on any position // *************************** circ = new CircularOrbit(7178000.0, 1.e-5, 0., FastMath.toRadians(50.), 0., FastMath.toRadians(90.), PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu); // Get nadir attitude rotNadir = nadirAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation(); // Get earth center attitude rotCenter = earthCenterAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation(); // For a satellite at any position, earth center pointing attitude and nadir pointing // and nadir pointing attitude shall not be the same, i.e the composition of inverse earth // pointing rotation with nadir pointing rotation shall be different from identity. rotCompo = rotCenter.applyInverseTo(rotNadir); angle = rotCompo.getAngle(); Assert.assertEquals(angle, FastMath.toRadians(0.16797386586252272), Utils.epsilonAngle); }
From source file:org.orekit.attitudes.TargetPointingTest.java
/** Test if both constructors are equivalent *///from ww w . j a va 2s. c om @Test public void testConstructors() throws OrekitException { // Satellite position // ******************** CircularOrbit circ = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.), FastMath.toRadians(270.), FastMath.toRadians(5.300), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); // Attitude laws // *************** // Elliptic earth shape OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, itrf); // Target definition as a geodetic point AND as a position/velocity vector GeodeticPoint geoTargetITRF2005C = new GeodeticPoint(FastMath.toRadians(43.36), FastMath.toRadians(1.26), 600.); Vector3D pTargetITRF2005C = earthShape.transform(geoTargetITRF2005C); // Attitude law definition from geodetic point target TargetPointing geoTargetAttitudeLaw = new TargetPointing(circ.getFrame(), geoTargetITRF2005C, earthShape); // Attitude law definition from position/velocity target TargetPointing pvTargetAttitudeLaw = new TargetPointing(circ.getFrame(), itrf, pTargetITRF2005C); // Check that both attitude are the same // Get satellite rotation for target pointing law Rotation rotPv = pvTargetAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation(); // Get satellite rotation for nadir pointing law Rotation rotGeo = geoTargetAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation(); // Rotations composition Rotation rotCompo = rotGeo.applyInverseTo(rotPv); double angle = rotCompo.getAngle(); Assert.assertEquals(angle, 0.0, Utils.epsilonAngle); }
From source file:org.orekit.attitudes.TargetPointingTest.java
/** Test with nadir target : Check that when the target is the same as nadir target at date, * satellite attitude is the same as nadir attitude at the same date, but different at a different date. *///from w w w. ja va2 s .c om @Test public void testNadirTarget() throws OrekitException { // Elliptic earth shape OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, itrf); // Satellite on any position CircularOrbit circOrbit = new CircularOrbit(7178000.0, 1.e-5, 0., FastMath.toRadians(50.), 0., FastMath.toRadians(90.), PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu); // Target attitude provider with target under satellite nadir // ******************************************************* // Definition of nadir target // Create nadir pointing attitude provider NadirPointing nadirAttitudeLaw = new NadirPointing(circOrbit.getFrame(), earthShape); // Check nadir target Vector3D pNadirTarget = nadirAttitudeLaw.getTargetPV(circOrbit, date, itrf).getPosition(); GeodeticPoint geoNadirTarget = earthShape.transform(pNadirTarget, itrf, date); // Create target attitude provider TargetPointing targetAttitudeLaw = new TargetPointing(circOrbit.getFrame(), geoNadirTarget, earthShape); // 1/ Test that attitudes are the same at date // ********************************************* // i.e the composition of inverse earth pointing rotation // with nadir pointing rotation shall be identity. // Get satellite rotation from target pointing law at date Rotation rotTarget = targetAttitudeLaw.getAttitude(circOrbit, date, circOrbit.getFrame()).getRotation(); // Get satellite rotation from nadir pointing law at date Rotation rotNadir = nadirAttitudeLaw.getAttitude(circOrbit, date, circOrbit.getFrame()).getRotation(); // Compose attitude rotations Rotation rotCompo = rotTarget.applyInverseTo(rotNadir); double angle = rotCompo.getAngle(); Assert.assertEquals(angle, 0.0, Utils.epsilonAngle); // 2/ Test that attitudes are different at a different date // ********************************************************** // Extrapolation one minute later KeplerianPropagator extrapolator = new KeplerianPropagator(circOrbit); double delta_t = 60.0; // extrapolation duration in seconds AbsoluteDate extrapDate = date.shiftedBy(delta_t); Orbit extrapOrbit = extrapolator.propagate(extrapDate).getOrbit(); // Get satellite rotation from target pointing law at date + 1min Rotation extrapRotTarget = targetAttitudeLaw.getAttitude(extrapOrbit, extrapDate, extrapOrbit.getFrame()) .getRotation(); // Get satellite rotation from nadir pointing law at date Rotation extrapRotNadir = nadirAttitudeLaw.getAttitude(extrapOrbit, extrapDate, extrapOrbit.getFrame()) .getRotation(); // Compose attitude rotations Rotation extrapRotCompo = extrapRotTarget.applyInverseTo(extrapRotNadir); double extrapAngle = extrapRotCompo.getAngle(); Assert.assertEquals(extrapAngle, FastMath.toRadians(24.684793905118823), Utils.epsilonAngle); }
From source file:org.orekit.frames.ITRFProviderWithoutTidalEffectsTest.java
@Test public void testMSLIBTransformJ2000_TerRef() throws OrekitException { AbsoluteDate t0 = new AbsoluteDate(new DateComponents(2003, 10, 14), new TimeComponents(02, 00, 00), TimeScalesFactory.getUTC()); Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true); Transform trans = FramesFactory.getEME2000().getTransformTo(itrf, t0); // Coordinates in EME2000 PVCoordinates pvEME2000 = new PVCoordinates(new Vector3D(6500000.0, -1234567.0, 4000000.0), new Vector3D(3609.28229, 3322.88979, -7083.950661)); // Reference coordinates in ITRF PVCoordinates pvRef = new PVCoordinates( new Vector3D(3011113.971820046, -5889827.854375269, 4002158.938875904), new Vector3D(4410.393506651586, -1033.61784235127, -7082.633883124906)); // tests using direct transform checkPV(pvRef, trans.transformPVCoordinates(pvEME2000), 0.594, 1.79e-4); // compute local evolution using finite differences double h = 1.0; Rotation r0 = trans.getRotation();//from w ww .j a va 2 s .c o m AbsoluteDate date = t0.shiftedBy(-2 * h); Rotation evoM2h = FramesFactory.getEME2000().getTransformTo(itrf, date).getRotation().applyTo(r0.revert()); double alphaM2h = -evoM2h.getAngle(); Vector3D axisM2h = evoM2h.getAxis(); date = t0.shiftedBy(-h); Rotation evoM1h = FramesFactory.getEME2000().getTransformTo(itrf, date).getRotation().applyTo(r0.revert()); double alphaM1h = -evoM1h.getAngle(); Vector3D axisM1h = evoM1h.getAxis(); date = t0.shiftedBy(h); Rotation evoP1h = FramesFactory.getEME2000().getTransformTo(itrf, date).getRotation().applyTo(r0.revert()); double alphaP1h = evoP1h.getAngle(); Vector3D axisP1h = evoP1h.getAxis().negate(); date = t0.shiftedBy(2 * h); Rotation evoP2h = FramesFactory.getEME2000().getTransformTo(itrf, date).getRotation().applyTo(r0.revert()); double alphaP2h = evoP2h.getAngle(); Vector3D axisP2h = evoP2h.getAxis().negate(); double w = (8 * (alphaP1h - alphaM1h) - (alphaP2h - alphaM2h)) / (12 * h); Vector3D axis = axisM2h.add(axisM1h).add(axisP1h.add(axisP2h)).normalize(); Transform finiteDiffTransform = new Transform(t0, trans.getRotation(), new Vector3D(w, axis)); checkPV(pvRef, finiteDiffTransform.transformPVCoordinates(pvEME2000), 0.594, 1.78e-4); }
From source file:org.orekit.frames.TransformTest.java
@Test public void testRotPV() { RandomGenerator rnd = new Well19937a(0x73d5554d99427af0l); // Instant Rotation only for (int i = 0; i < 10; ++i) { // Random instant rotation Rotation instantRot = randomRotation(rnd); Vector3D normAxis = instantRot.getAxis(); double w = FastMath.abs(instantRot.getAngle()) / Constants.JULIAN_DAY; // random rotation Rotation rot = randomRotation(rnd); // so we have a transform Transform tr = new Transform(AbsoluteDate.J2000_EPOCH, rot, new Vector3D(w, normAxis)); // random position, velocity, acceleration Vector3D pos = randomVector(1.0e3, rnd); Vector3D vel = randomVector(1.0, rnd); Vector3D acc = randomVector(1.0e-3, rnd); PVCoordinates pvOne = new PVCoordinates(pos, vel, acc); // we obtain PVCoordinates pvTwo = tr.transformPVCoordinates(pvOne); // test inverse Vector3D resultvel = tr.getInverse().transformPVCoordinates(pvTwo).getVelocity(); checkVector(resultvel, vel, 1.0e-15); }/*from w w w. j a va2 s.co m*/ }
From source file:org.orekit.frames.TransformTest.java
@Test public void testRotation() { RandomGenerator rnd = new Well19937a(0x73d5554d99427af0l); for (int i = 0; i < 10; ++i) { Rotation r = randomRotation(rnd); Vector3D axis = r.getAxis(); double angle = r.getAngle(); Transform transform = new Transform(AbsoluteDate.J2000_EPOCH, r); for (int j = 0; j < 10; ++j) { Vector3D a = new Vector3D(rnd.nextDouble(), rnd.nextDouble(), rnd.nextDouble()); Vector3D b = transform.transformVector(a); Assert.assertEquals(Vector3D.angle(axis, a), Vector3D.angle(axis, b), 1.0e-14); Vector3D aOrtho = Vector3D.crossProduct(axis, a); Vector3D bOrtho = Vector3D.crossProduct(axis, b); Assert.assertEquals(angle, Vector3D.angle(aOrtho, bOrtho), 1.0e-14); Vector3D c = transform.transformPosition(a); Assert.assertEquals(0, c.subtract(b).getNorm(), 1.0e-14); }/*from w ww . j a v a2 s . com*/ } }