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.orbits.CircularParametersTest.java
@Test public void testPerfectlyEquatorial() throws OrekitException { Vector3D position = new Vector3D(-7293947.695148368, 5122184.668436634, 0.0); Vector3D velocity = new Vector3D(-3890.4029433398, -5369.811285264604, 0.0); CircularOrbit orbit = new CircularOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), new AbsoluteDate("2004-01-01T23:00:00.000", TimeScalesFactory.getUTC()), 3.986004415E14); Assert.assertEquals(0.0, orbit.getI(), 2.0e-14); Assert.assertEquals(0.0, orbit.getRightAscensionOfAscendingNode(), 2.0e-14); }
From source file:org.orekit.orbits.CircularParametersTest.java
@Test public void testSymmetryEll() { // elliptic and non equatorail orbit Vector3D position = new Vector3D(4512.9, 18260., -5127.); Vector3D velocity = new Vector3D(134664.6, 90066.8, 72047.6); PVCoordinates pvCoordinates = new PVCoordinates(position, velocity); CircularOrbit p = new CircularOrbit(pvCoordinates, FramesFactory.getEME2000(), date, mu); Vector3D positionOffset = p.getPVCoordinates().getPosition(); Vector3D velocityOffset = p.getPVCoordinates().getVelocity(); positionOffset = positionOffset.subtract(position); velocityOffset = velocityOffset.subtract(velocity); Assert.assertEquals(0.0, positionOffset.getNorm(), position.getNorm() * Utils.epsilonTest); Assert.assertEquals(0.0, velocityOffset.getNorm(), velocity.getNorm() * Utils.epsilonTest); }
From source file:org.orekit.orbits.CircularParametersTest.java
@Test public void testSymmetryCir() { // circular and equatorial orbit Vector3D position = new Vector3D(33051.2, 26184.9, -1.3E-5); Vector3D velocity = new Vector3D(-60376.2, 76208., 2.7E-4); PVCoordinates pvCoordinates = new PVCoordinates(position, velocity); CircularOrbit p = new CircularOrbit(pvCoordinates, FramesFactory.getEME2000(), date, mu); Vector3D positionOffset = p.getPVCoordinates().getPosition().subtract(position); Vector3D velocityOffset = p.getPVCoordinates().getVelocity().subtract(velocity); Assert.assertEquals(0.0, positionOffset.getNorm(), position.getNorm() * Utils.epsilonTest); Assert.assertEquals(0.0, velocityOffset.getNorm(), velocity.getNorm() * Utils.epsilonTest); }
From source file:org.orekit.orbits.CircularParametersTest.java
@Test(expected = IllegalArgumentException.class) public void testNonInertialFrame() throws IllegalArgumentException { Vector3D position = new Vector3D(33051.2, 26184.9, -1.3E-5); Vector3D velocity = new Vector3D(-60376.2, 76208., 2.7E-4); PVCoordinates pvCoordinates = new PVCoordinates(position, velocity); new CircularOrbit(pvCoordinates, new Frame(FramesFactory.getEME2000(), Transform.IDENTITY, "non-inertial", false), date, mu); }
From source file:org.orekit.orbits.CircularParametersTest.java
@Test public void testJacobianReference() throws OrekitException { AbsoluteDate dateTca = new AbsoluteDate(2000, 04, 01, 0, 0, 0.000, TimeScalesFactory.getUTC()); double mu = 3.986004415e+14; CircularOrbit orbCir = new CircularOrbit(7000000.0, 0.01, -0.02, 1.2, 2.1, 0.7, PositionAngle.MEAN, FramesFactory.getEME2000(), dateTca, mu); // the following reference values have been computed using the free software // version 6.2 of the MSLIB fortran library by the following program: // program cir_jacobian ///*from w w w . j a v a 2 s. com*/ // use mslib // implicit none // // integer, parameter :: nb = 11 // integer :: i,j // type(tm_code_retour) :: code_retour // // real(pm_reel), parameter :: mu= 3.986004415e+14_pm_reel // real(pm_reel),dimension(3)::vit_car,pos_car // type(tm_orb_cir)::cir // real(pm_reel), dimension(6,6)::jacob // real(pm_reel)::norme // // // cir%a=7000000_pm_reel // cir%ex=0.01_pm_reel // cir%ey=-0.02_pm_reel // cir%i=1.2_pm_reel // cir%gom=2.1_pm_reel // cir%pso_M=0.7_pm_reel // // call mv_cir_car(mu,cir,pos_car,vit_car,code_retour) // write(*,*)code_retour%valeur // write(*,1000)pos_car,vit_car // // // call mu_norme(pos_car,norme,code_retour) // write(*,*)norme // // call mv_car_cir (mu, pos_car, vit_car, cir, code_retour, jacob) // write(*,*)code_retour%valeur // // write(*,*)"circular = ", cir%a, cir%ex, cir%ey, cir%i, cir%gom, cir%pso_M // // do i = 1,6 // write(*,*) " ",(jacob(i,j),j=1,6) // end do // // 1000 format (6(f24.15,1x)) // end program cir_jacobian Vector3D pRef = new Vector3D(-4106905.105389204807580, 3603162.539798960555345, 4439730.167038885876536); Vector3D vRef = new Vector3D(740.132407342422994, -5308.773280141396754, 5250.338353483879473); double[][] jRef = { { -1.1535467596325562, 1.0120556393573172, 1.2470306024626943, 181.96913090864561, -1305.2162699469984, 1290.8494448855752 }, { -5.07367368325471104E-008, -1.27870567070456834E-008, 1.31544531338558113E-007, -3.09332106417043592E-005, -9.60781276304445404E-005, 1.91506964883791605E-004 }, { -6.59428471712402018E-008, 1.24561703203882533E-007, -1.41907027322388158E-008, 7.63442601186485441E-005, -1.77446722746170009E-004, 5.99464401287846734E-005 }, { 7.55079920652274275E-008, 4.41606835295069131E-008, 3.40079310688458225E-008, 7.89724635377817962E-005, 4.61868720707717372E-005, 3.55682891687782599E-005 }, { -9.20788748896973282E-008, -5.38521280004949642E-008, -4.14712660805579618E-008, 7.78626692360739821E-005, 4.55378113077967091E-005, 3.50684505810897702E-005 }, { 1.85082436324531617E-008, 1.20506219457886855E-007, -8.31277842285972640E-008, 1.27364008345789645E-004, -1.54770720974742483E-004, -1.78589436862677754E-004 } }; PVCoordinates pv = orbCir.getPVCoordinates(); Assert.assertEquals(0, pv.getPosition().subtract(pRef).getNorm(), 3.0e-16 * pRef.getNorm()); Assert.assertEquals(0, pv.getVelocity().subtract(vRef).getNorm(), 2.0e-16 * vRef.getNorm()); double[][] jacobian = new double[6][6]; orbCir.getJacobianWrtCartesian(PositionAngle.MEAN, jacobian); for (int i = 0; i < jacobian.length; i++) { double[] row = jacobian[i]; double[] rowRef = jRef[i]; for (int j = 0; j < row.length; j++) { Assert.assertEquals(0, (row[j] - rowRef[j]) / rowRef[j], 5.0e-15); } } }
From source file:org.orekit.orbits.CircularParametersTest.java
private void fillColumn(PositionAngle type, int i, CircularOrbit orbit, double hP, double[][] jacobian) { // at constant energy (i.e. constant semi major axis), we have dV = -mu dP / (V * r^2) // we use this to compute a velocity step size from the position step size Vector3D p = orbit.getPVCoordinates().getPosition(); Vector3D v = orbit.getPVCoordinates().getVelocity(); double hV = orbit.getMu() * hP / (v.getNorm() * p.getNormSq()); double h;//from w w w .j a va 2s .c o m Vector3D dP = Vector3D.ZERO; Vector3D dV = Vector3D.ZERO; switch (i) { case 0: h = hP; dP = new Vector3D(hP, 0, 0); break; case 1: h = hP; dP = new Vector3D(0, hP, 0); break; case 2: h = hP; dP = new Vector3D(0, 0, hP); break; case 3: h = hV; dV = new Vector3D(hV, 0, 0); break; case 4: h = hV; dV = new Vector3D(0, hV, 0); break; default: h = hV; dV = new Vector3D(0, 0, hV); break; } CircularOrbit oM4h = new CircularOrbit( new PVCoordinates(new Vector3D(1, p, -4, dP), new Vector3D(1, v, -4, dV)), orbit.getFrame(), orbit.getDate(), orbit.getMu()); CircularOrbit oM3h = new CircularOrbit( new PVCoordinates(new Vector3D(1, p, -3, dP), new Vector3D(1, v, -3, dV)), orbit.getFrame(), orbit.getDate(), orbit.getMu()); CircularOrbit oM2h = new CircularOrbit( new PVCoordinates(new Vector3D(1, p, -2, dP), new Vector3D(1, v, -2, dV)), orbit.getFrame(), orbit.getDate(), orbit.getMu()); CircularOrbit oM1h = new CircularOrbit( new PVCoordinates(new Vector3D(1, p, -1, dP), new Vector3D(1, v, -1, dV)), orbit.getFrame(), orbit.getDate(), orbit.getMu()); CircularOrbit oP1h = new CircularOrbit( new PVCoordinates(new Vector3D(1, p, +1, dP), new Vector3D(1, v, +1, dV)), orbit.getFrame(), orbit.getDate(), orbit.getMu()); CircularOrbit oP2h = new CircularOrbit( new PVCoordinates(new Vector3D(1, p, +2, dP), new Vector3D(1, v, +2, dV)), orbit.getFrame(), orbit.getDate(), orbit.getMu()); CircularOrbit oP3h = new CircularOrbit( new PVCoordinates(new Vector3D(1, p, +3, dP), new Vector3D(1, v, +3, dV)), orbit.getFrame(), orbit.getDate(), orbit.getMu()); CircularOrbit oP4h = new CircularOrbit( new PVCoordinates(new Vector3D(1, p, +4, dP), new Vector3D(1, v, +4, dV)), orbit.getFrame(), orbit.getDate(), orbit.getMu()); jacobian[0][i] = (-3 * (oP4h.getA() - oM4h.getA()) + 32 * (oP3h.getA() - oM3h.getA()) - 168 * (oP2h.getA() - oM2h.getA()) + 672 * (oP1h.getA() - oM1h.getA())) / (840 * h); jacobian[1][i] = (-3 * (oP4h.getCircularEx() - oM4h.getCircularEx()) + 32 * (oP3h.getCircularEx() - oM3h.getCircularEx()) - 168 * (oP2h.getCircularEx() - oM2h.getCircularEx()) + 672 * (oP1h.getCircularEx() - oM1h.getCircularEx())) / (840 * h); jacobian[2][i] = (-3 * (oP4h.getCircularEy() - oM4h.getCircularEy()) + 32 * (oP3h.getCircularEy() - oM3h.getCircularEy()) - 168 * (oP2h.getCircularEy() - oM2h.getCircularEy()) + 672 * (oP1h.getCircularEy() - oM1h.getCircularEy())) / (840 * h); jacobian[3][i] = (-3 * (oP4h.getI() - oM4h.getI()) + 32 * (oP3h.getI() - oM3h.getI()) - 168 * (oP2h.getI() - oM2h.getI()) + 672 * (oP1h.getI() - oM1h.getI())) / (840 * h); jacobian[4][i] = (-3 * (oP4h.getRightAscensionOfAscendingNode() - oM4h.getRightAscensionOfAscendingNode()) + 32 * (oP3h.getRightAscensionOfAscendingNode() - oM3h.getRightAscensionOfAscendingNode()) - 168 * (oP2h.getRightAscensionOfAscendingNode() - oM2h.getRightAscensionOfAscendingNode()) + 672 * (oP1h.getRightAscensionOfAscendingNode() - oM1h.getRightAscensionOfAscendingNode())) / (840 * h); jacobian[5][i] = (-3 * (oP4h.getAlpha(type) - oM4h.getAlpha(type)) + 32 * (oP3h.getAlpha(type) - oM3h.getAlpha(type)) - 168 * (oP2h.getAlpha(type) - oM2h.getAlpha(type)) + 672 * (oP1h.getAlpha(type) - oM1h.getAlpha(type))) / (840 * h); }
From source file:org.orekit.orbits.CircularParametersTest.java
@Test public void testInterpolation() throws OrekitException { final double ehMu = 3.9860047e14; final double ae = 6.378137e6; final double c20 = -1.08263e-3; final double c30 = 2.54e-6; final double c40 = 1.62e-6; final double c50 = 2.3e-7; final double c60 = -5.5e-7; final AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(584.); final Vector3D position = new Vector3D(3220103., 69623., 6449822.); final Vector3D velocity = new Vector3D(6414.7, -2006., -3180.); final CircularOrbit initialOrbit = new CircularOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, ehMu); EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(initialOrbit, ae, ehMu, c20, c30, c40, c50, c60);/* w w w . j a v a 2 s . com*/ // set up a 5 points sample List<Orbit> sample = new ArrayList<Orbit>(); for (double dt = 0; dt < 300.0; dt += 60.0) { sample.add(propagator.propagate(date.shiftedBy(dt)).getOrbit()); } // well inside the sample, interpolation should be much better than Keplerian shift double maxShiftError = 0; double maxInterpolationError = 0; for (double dt = 0; dt < 241.0; dt += 1.0) { AbsoluteDate t = initialOrbit.getDate().shiftedBy(dt); Vector3D shifted = initialOrbit.shiftedBy(dt).getPVCoordinates().getPosition(); Vector3D interpolated = initialOrbit.interpolate(t, sample).getPVCoordinates().getPosition(); Vector3D propagated = propagator.propagate(t).getPVCoordinates().getPosition(); maxShiftError = FastMath.max(maxShiftError, shifted.subtract(propagated).getNorm()); maxInterpolationError = FastMath.max(maxInterpolationError, interpolated.subtract(propagated).getNorm()); } Assert.assertTrue(maxShiftError > 390.0); Assert.assertTrue(maxInterpolationError < 0.04); // slightly past sample end, interpolation should quickly increase, but remain reasonable maxShiftError = 0; maxInterpolationError = 0; for (double dt = 240; dt < 300.0; dt += 1.0) { AbsoluteDate t = initialOrbit.getDate().shiftedBy(dt); Vector3D shifted = initialOrbit.shiftedBy(dt).getPVCoordinates().getPosition(); Vector3D interpolated = initialOrbit.interpolate(t, sample).getPVCoordinates().getPosition(); Vector3D propagated = propagator.propagate(t).getPVCoordinates().getPosition(); maxShiftError = FastMath.max(maxShiftError, shifted.subtract(propagated).getNorm()); maxInterpolationError = FastMath.max(maxInterpolationError, interpolated.subtract(propagated).getNorm()); } Assert.assertTrue(maxShiftError < 610.0); Assert.assertTrue(maxInterpolationError < 1.3); // far past sample end, interpolation should become really wrong // (in this test case, break even occurs at around 863 seconds, with a 3.9 km error) maxShiftError = 0; maxInterpolationError = 0; for (double dt = 300; dt < 1000; dt += 1.0) { AbsoluteDate t = initialOrbit.getDate().shiftedBy(dt); Vector3D shifted = initialOrbit.shiftedBy(dt).getPVCoordinates().getPosition(); Vector3D interpolated = initialOrbit.interpolate(t, sample).getPVCoordinates().getPosition(); Vector3D propagated = propagator.propagate(t).getPVCoordinates().getPosition(); maxShiftError = FastMath.max(maxShiftError, shifted.subtract(propagated).getNorm()); maxInterpolationError = FastMath.max(maxInterpolationError, interpolated.subtract(propagated).getNorm()); } Assert.assertTrue(maxShiftError < 5000.0); Assert.assertTrue(maxInterpolationError > 8800.0); }
From source file:org.orekit.orbits.CircularParametersTest.java
@Test public void testSerialization() throws IOException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException { Vector3D position = new Vector3D(-29536113.0, 30329259.0, -100125.0); Vector3D velocity = new Vector3D(-2194.0, -2141.0, -8.0); PVCoordinates pvCoordinates = new PVCoordinates(position, velocity); CircularOrbit orbit = new CircularOrbit(pvCoordinates, FramesFactory.getEME2000(), date, mu); Assert.assertEquals(42255170.003, orbit.getA(), 1.0e-3); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(orbit);/* ww w. ja v a 2 s . c o m*/ Assert.assertTrue(bos.size() > 350); Assert.assertTrue(bos.size() < 400); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bis); CircularOrbit deserialized = (CircularOrbit) ois.readObject(); Assert.assertEquals(orbit.getA(), deserialized.getA(), 1.0e-10); Assert.assertEquals(orbit.getCircularEx(), deserialized.getCircularEx(), 1.0e-10); Assert.assertEquals(orbit.getCircularEy(), deserialized.getCircularEy(), 1.0e-10); Assert.assertEquals(orbit.getRightAscensionOfAscendingNode(), deserialized.getRightAscensionOfAscendingNode(), 1.0e-10); Assert.assertEquals(orbit.getAlphaV(), deserialized.getAlphaV(), 1.0e-10); Assert.assertEquals(orbit.getDate(), deserialized.getDate()); Assert.assertEquals(orbit.getMu(), deserialized.getMu(), 1.0e-10); Assert.assertEquals(orbit.getFrame().getName(), deserialized.getFrame().getName()); }
From source file:org.orekit.orbits.EquinoctialOrbit.java
/** {@inheritDoc} */ protected TimeStampedPVCoordinates initPVCoordinates() { // get equinoctial parameters final double lE = getLE(); // inclination-related intermediate parameters final double hx2 = hx * hx; final double hy2 = hy * hy; final double factH = 1. / (1 + hx2 + hy2); // reference axes defining the orbital plane final double ux = (1 + hx2 - hy2) * factH; final double uy = 2 * hx * hy * factH; final double uz = -2 * hy * factH; final double vx = uy; final double vy = (1 - hx2 + hy2) * factH; final double vz = 2 * hx * factH; // eccentricity-related intermediate parameters final double exey = ex * ey; final double ex2 = ex * ex; final double ey2 = ey * ey; final double e2 = ex2 + ey2; final double eta = 1 + FastMath.sqrt(1 - e2); final double beta = 1. / eta; // eccentric longitude argument final double cLe = FastMath.cos(lE); final double sLe = FastMath.sin(lE); final double exCeyS = ex * cLe + ey * sLe; // coordinates of position and velocity in the orbital plane final double x = a * ((1 - beta * ey2) * cLe + beta * exey * sLe - ex); final double y = a * ((1 - beta * ex2) * sLe + beta * exey * cLe - ey); final double factor = FastMath.sqrt(getMu() / a) / (1 - exCeyS); final double xdot = factor * (-sLe + beta * ey * exCeyS); final double ydot = factor * (cLe - beta * ex * exCeyS); final Vector3D position = new Vector3D(x * ux + y * vx, x * uy + y * vy, x * uz + y * vz); final double r2 = position.getNormSq(); final Vector3D velocity = new Vector3D(xdot * ux + ydot * vx, xdot * uy + ydot * vy, xdot * uz + ydot * vz); final Vector3D acceleration = new Vector3D(-getMu() / (r2 * FastMath.sqrt(r2)), position); return new TimeStampedPVCoordinates(getDate(), position, velocity, acceleration); }
From source file:org.orekit.orbits.EquinoctialOrbit.java
/** {@inheritDoc} */ protected double[][] computeJacobianMeanWrtCartesian() { final double[][] jacobian = new double[6][6]; // compute various intermediate parameters final Vector3D position = getPVCoordinates().getPosition(); final Vector3D velocity = getPVCoordinates().getVelocity(); final double r2 = position.getNormSq(); final double r = FastMath.sqrt(r2); final double r3 = r * r2; final double mu = getMu(); final double sqrtMuA = FastMath.sqrt(a * mu); final double a2 = a * a; final double e2 = ex * ex + ey * ey; final double oMe2 = 1 - e2; final double epsilon = FastMath.sqrt(oMe2); final double beta = 1 / (1 + epsilon); final double ratio = epsilon * beta; final double hx2 = hx * hx; final double hy2 = hy * hy; final double hxhy = hx * hy; // precomputing equinoctial frame unit vectors (f,g,w) final Vector3D f = new Vector3D(1 - hy2 + hx2, 2 * hxhy, -2 * hy).normalize(); final Vector3D g = new Vector3D(2 * hxhy, 1 + hy2 - hx2, 2 * hx).normalize(); final Vector3D w = Vector3D.crossProduct(position, velocity).normalize(); // coordinates of the spacecraft in the equinoctial frame final double x = Vector3D.dotProduct(position, f); final double y = Vector3D.dotProduct(position, g); final double xDot = Vector3D.dotProduct(velocity, f); final double yDot = Vector3D.dotProduct(velocity, g); // drDot / dEx = dXDot / dEx * f + dYDot / dEx * g final double c1 = a / (sqrtMuA * epsilon); final double c2 = a * sqrtMuA * beta / r3; final double c3 = sqrtMuA / (r3 * epsilon); final Vector3D drDotSdEx = new Vector3D(c1 * xDot * yDot - c2 * ey * x - c3 * x * y, f, -c1 * xDot * xDot - c2 * ey * y + c3 * x * x, g); // drDot / dEy = dXDot / dEy * f + dYDot / dEy * g final Vector3D drDotSdEy = new Vector3D(c1 * yDot * yDot + c2 * ex * x - c3 * y * y, f, -c1 * xDot * yDot + c2 * ex * y + c3 * x * y, g); // da//from w w w. ja v a2 s .c o m final Vector3D vectorAR = new Vector3D(2 * a2 / r3, position); final Vector3D vectorARDot = new Vector3D(2 * a2 / mu, velocity); fillHalfRow(1, vectorAR, jacobian[0], 0); fillHalfRow(1, vectorARDot, jacobian[0], 3); // dEx final double d1 = -a * ratio / r3; final double d2 = (hy * xDot - hx * yDot) / (sqrtMuA * epsilon); final double d3 = (hx * y - hy * x) / sqrtMuA; final Vector3D vectorExRDot = new Vector3D((2 * x * yDot - xDot * y) / mu, g, -y * yDot / mu, f, -ey * d3 / epsilon, w); fillHalfRow(ex * d1, position, -ey * d2, w, epsilon / sqrtMuA, drDotSdEy, jacobian[1], 0); fillHalfRow(1, vectorExRDot, jacobian[1], 3); // dEy final Vector3D vectorEyRDot = new Vector3D((2 * xDot * y - x * yDot) / mu, f, -x * xDot / mu, g, ex * d3 / epsilon, w); fillHalfRow(ey * d1, position, ex * d2, w, -epsilon / sqrtMuA, drDotSdEx, jacobian[2], 0); fillHalfRow(1, vectorEyRDot, jacobian[2], 3); // dHx final double h = (1 + hx2 + hy2) / (2 * sqrtMuA * epsilon); fillHalfRow(-h * xDot, w, jacobian[3], 0); fillHalfRow(h * x, w, jacobian[3], 3); // dHy fillHalfRow(-h * yDot, w, jacobian[4], 0); fillHalfRow(h * y, w, jacobian[4], 3); // dLambdaM final double l = -ratio / sqrtMuA; fillHalfRow(-1 / sqrtMuA, velocity, d2, w, l * ex, drDotSdEx, l * ey, drDotSdEy, jacobian[5], 0); fillHalfRow(-2 / sqrtMuA, position, ex * beta, vectorEyRDot, -ey * beta, vectorExRDot, d3, w, jacobian[5], 3); return jacobian; }