List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D normalize
public Vector3D normalize() throws MathArithmeticException
From source file:org.orekit.forces.SphericalSpacecraftTest.java
@Test public void testDrag() throws OrekitException { AbsoluteDate date = new AbsoluteDate(new DateComponents(2008, 04, 07), TimeComponents.H00, TimeScalesFactory.getTAI()); // Satellite position as circular parameters final double mu = 3.9860047e14; final double raan = 270.; Orbit circ = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.), FastMath.toRadians(raan), FastMath.toRadians(5.300 - raan), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); SpacecraftState state = new SpacecraftState(circ); double surface = 5.0; double cd = 2.0; SphericalSpacecraft s = new SphericalSpacecraft(surface, cd, 0.0, 0.0); Vector3D relativeVelocity = new Vector3D(36.0, 48.0, 80.0); double rho = 0.001; Vector3D computedAcceleration = s.dragAcceleration(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation(), state.getMass(), rho, relativeVelocity);/* w w w . ja v a 2s .c o m*/ Vector3D d = relativeVelocity.normalize(); double v2 = relativeVelocity.getNormSq(); Vector3D expectedAcceleration = new Vector3D(rho * surface * cd * v2 / (2 * state.getMass()), d); Assert.assertEquals(0.0, computedAcceleration.subtract(expectedAcceleration).getNorm(), 1.0e-15); }
From source file:org.orekit.forces.SphericalSpacecraftTest.java
@Test public void testRadiationPressure() throws OrekitException { AbsoluteDate date = new AbsoluteDate(new DateComponents(2008, 04, 07), TimeComponents.H00, TimeScalesFactory.getTAI()); // Satellite position as circular parameters final double mu = 3.9860047e14; final double raan = 270.; Orbit circ = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.), FastMath.toRadians(raan), FastMath.toRadians(5.300 - raan), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); SpacecraftState state = new SpacecraftState(circ); double surface = 5.0; double kA = 0.9; double kR = 0.1; SphericalSpacecraft s = new SphericalSpacecraft(surface, 0.0, kA, kR); Vector3D flux = new Vector3D(36.0, 48.0, 80.0); Vector3D computedAcceleration = s.radiationPressureAcceleration(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation(), state.getMass(), flux); Vector3D d = flux.normalize(); double f = flux.getNorm(); double p = (1 - kA) * (1 - kR); Vector3D expectedAcceleration = new Vector3D(surface * f * (1 + 4 * p / 9) / state.getMass(), d); Assert.assertEquals(0.0, computedAcceleration.subtract(expectedAcceleration).getNorm(), 1.0e-15); }
From source file:org.orekit.models.earth.tessellation.AlongTrackAiming.java
/** {@inheritDoc} */ @Override/*from w w w . j a va2 s.c o m*/ public Vector3D alongTileDirection(final Vector3D point, final GeodeticPoint gp) throws OrekitException { final double lStart = halfTrack.get(0).getFirst().getLatitude(); final double lEnd = halfTrack.get(halfTrack.size() - 1).getFirst().getLatitude(); // check the point can be reached if (gp.getLatitude() < FastMath.min(lStart, lEnd) || gp.getLatitude() > FastMath.max(lStart, lEnd)) { throw new OrekitException(OrekitMessages.OUT_OF_RANGE_LATITUDE, FastMath.toDegrees(gp.getLatitude()), FastMath.toDegrees(FastMath.min(lStart, lEnd)), FastMath.toDegrees(FastMath.max(lStart, lEnd))); } // bracket the point in the half track sample int iInf = 0; int iSup = halfTrack.size() - 1; while (iSup - iInf > 1) { final int iMiddle = (iSup + iInf) / 2; if ((lStart < lEnd) ^ (halfTrack.get(iMiddle).getFirst().getLatitude() > gp.getLatitude())) { // the specified latitude is in the second half iInf = iMiddle; } else { // the specified latitude is in the first half iSup = iMiddle; } } // ensure we can get points at iStart, iStart + 1, iStart + 2 and iStart + 3 final int iStart = FastMath.max(0, FastMath.min(iInf - 1, halfTrack.size() - 4)); // interpolate ground sliding point at specified latitude final HermiteInterpolator interpolator = new HermiteInterpolator(); for (int i = iStart; i < iStart + 4; ++i) { final Vector3D position = halfTrack.get(i).getSecond().getPosition(); final Vector3D velocity = halfTrack.get(i).getSecond().getVelocity(); interpolator.addSamplePoint(halfTrack.get(i).getFirst().getLatitude(), new double[] { position.getX(), position.getY(), position.getZ(), velocity.getX(), velocity.getY(), velocity.getZ() }); } final DerivativeStructure[] p = interpolator.value(new DerivativeStructure(1, 1, 0, gp.getLatitude())); // extract interpolated ground position/velocity final Vector3D position = new Vector3D(p[0].getValue(), p[1].getValue(), p[2].getValue()); final Vector3D velocity = new Vector3D(p[3].getValue(), p[4].getValue(), p[5].getValue()); // adjust longitude to match the specified one final Rotation rotation = new Rotation(Vector3D.PLUS_K, position, Vector3D.PLUS_K, point); final Vector3D fixedVelocity = rotation.applyTo(velocity); // the tile direction is aligned with sliding point velocity return fixedVelocity.normalize(); }
From source file:org.orekit.orbits.CartesianOrbit.java
/** Compute shifted position and velocity in elliptic case. * @param dt time shift//ww w .j a v a2 s . c o m * @return shifted position and velocity */ private PVCoordinates shiftPVElliptic(final double dt) { // preliminary computation final Vector3D pvP = getPVCoordinates().getPosition(); final Vector3D pvV = getPVCoordinates().getVelocity(); final double r = pvP.getNorm(); final double rV2OnMu = r * pvV.getNormSq() / getMu(); final double a = getA(); final double eSE = Vector3D.dotProduct(pvP, pvV) / FastMath.sqrt(getMu() * a); final double eCE = rV2OnMu - 1; final double e2 = eCE * eCE + eSE * eSE; // we can use any arbitrary reference 2D frame in the orbital plane // in order to simplify some equations below, we use the current position as the u axis final Vector3D u = pvP.normalize(); final Vector3D v = Vector3D.crossProduct(getPVCoordinates().getMomentum(), u).normalize(); // the following equations rely on the specific choice of u explained above, // some coefficients that vanish to 0 in this case have already been removed here final double ex = (eCE - e2) * a / r; final double ey = -FastMath.sqrt(1 - e2) * eSE * a / r; final double beta = 1 / (1 + FastMath.sqrt(1 - e2)); final double thetaE0 = FastMath.atan2(ey + eSE * beta * ex, r / a + ex - eSE * beta * ey); final double thetaM0 = thetaE0 - ex * FastMath.sin(thetaE0) + ey * FastMath.cos(thetaE0); // compute in-plane shifted eccentric argument final double thetaM1 = thetaM0 + getKeplerianMeanMotion() * dt; final double thetaE1 = meanToEccentric(thetaM1, ex, ey); final double cTE = FastMath.cos(thetaE1); final double sTE = FastMath.sin(thetaE1); // compute shifted in-plane cartesian coordinates final double exey = ex * ey; final double exCeyS = ex * cTE + ey * sTE; final double x = a * ((1 - beta * ey * ey) * cTE + beta * exey * sTE - ex); final double y = a * ((1 - beta * ex * ex) * sTE + beta * exey * cTE - ey); final double factor = FastMath.sqrt(getMu() / a) / (1 - exCeyS); final double xDot = factor * (-sTE + beta * ey * exCeyS); final double yDot = factor * (cTE - beta * ex * exCeyS); final Vector3D shiftedP = new Vector3D(x, u, y, v); final double r2 = x * x + y * y; final Vector3D shiftedV = new Vector3D(xDot, u, yDot, v); final Vector3D shiftedA = new Vector3D(-getMu() / (r2 * FastMath.sqrt(r2)), shiftedP); return new PVCoordinates(shiftedP, shiftedV, shiftedA); }
From source file:org.orekit.orbits.CartesianParametersTest.java
@Test public void testGeometry() { 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); Vector3D momentum = pvCoordinates.getMomentum().normalize(); EquinoctialOrbit p = new EquinoctialOrbit(pvCoordinates, FramesFactory.getEME2000(), date, mu); double apogeeRadius = p.getA() * (1 + p.getE()); double perigeeRadius = p.getA() * (1 - p.getE()); for (double lv = 0; lv <= 2 * FastMath.PI; lv += 2 * FastMath.PI / 100.) { p = new EquinoctialOrbit(p.getA(), p.getEquinoctialEx(), p.getEquinoctialEy(), p.getHx(), p.getHy(), lv, PositionAngle.TRUE, p.getFrame(), date, mu); position = p.getPVCoordinates().getPosition(); // test if the norm of the position is in the range [perigee radius, apogee radius] // Warning: these tests are without absolute value by choice Assert.assertTrue((position.getNorm() - apogeeRadius) <= (apogeeRadius * Utils.epsilonTest)); Assert.assertTrue((position.getNorm() - perigeeRadius) >= (-perigeeRadius * Utils.epsilonTest)); // Assert.assertTrue(position.getNorm() <= apogeeRadius); // Assert.assertTrue(position.getNorm() >= perigeeRadius); position = position.normalize(); velocity = p.getPVCoordinates().getVelocity().normalize(); // at this stage of computation, all the vectors (position, velocity and momemtum) are normalized here // test of orthogonality between position and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(position, momentum)) < Utils.epsilonTest); // test of orthogonality between velocity and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(velocity, momentum)) < Utils.epsilonTest); }//from ww w .ja va 2 s. c o m }
From source file:org.orekit.orbits.CircularParametersTest.java
@Test public void testGeometryEll() { // elliptic and non equatorial (i retrograde) orbit double hx = 1.2; double hy = 2.1; double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy)); double raan = FastMath.atan2(hy, hx); CircularOrbit p = new CircularOrbit(42166.712, 0.5, -0.5, i, raan, 0.67 - raan, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu); Vector3D position = p.getPVCoordinates().getPosition(); Vector3D velocity = p.getPVCoordinates().getVelocity(); Vector3D momentum = p.getPVCoordinates().getMomentum().normalize(); double apogeeRadius = p.getA() * (1 + p.getE()); double perigeeRadius = p.getA() * (1 - p.getE()); for (double alphaV = 0; alphaV <= 2 * FastMath.PI; alphaV += 2 * FastMath.PI / 100.) { p = new CircularOrbit(p.getA(), p.getCircularEx(), p.getCircularEy(), p.getI(), p.getRightAscensionOfAscendingNode(), alphaV, PositionAngle.TRUE, p.getFrame(), date, mu); position = p.getPVCoordinates().getPosition(); // test if the norm of the position is in the range [perigee radius, apogee radius] // Warning: these tests are without absolute value by choice Assert.assertTrue((position.getNorm() - apogeeRadius) <= (apogeeRadius * Utils.epsilonTest)); Assert.assertTrue((position.getNorm() - perigeeRadius) >= (-perigeeRadius * Utils.epsilonTest)); position = position.normalize(); velocity = p.getPVCoordinates().getVelocity(); velocity = velocity.normalize(); // at this stage of computation, all the vectors (position, velocity and momemtum) are normalized here // test of orthogonality between position and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(position, momentum)) < Utils.epsilonTest); // test of orthogonality between velocity and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(velocity, momentum)) < Utils.epsilonTest); }//from w w w .j a va 2s.c o m }
From source file:org.orekit.orbits.CircularParametersTest.java
@Test public void testGeometryCirc() { // circular and equatorial orbit double hx = 0.1e-8; double hy = 0.1e-8; double i = 2 * FastMath.atan(FastMath.sqrt(hx * hx + hy * hy)); double raan = FastMath.atan2(hy, hx); CircularOrbit pCirEqua = new CircularOrbit(42166.712, 0.1e-8, 0.1e-8, i, raan, 0.67 - raan, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu); Vector3D position = pCirEqua.getPVCoordinates().getPosition(); Vector3D velocity = pCirEqua.getPVCoordinates().getVelocity(); Vector3D momentum = pCirEqua.getPVCoordinates().getMomentum().normalize(); double apogeeRadius = pCirEqua.getA() * (1 + pCirEqua.getE()); double perigeeRadius = pCirEqua.getA() * (1 - pCirEqua.getE()); // test if apogee equals perigee Assert.assertEquals(perigeeRadius, apogeeRadius, 1.e+4 * Utils.epsilonTest * apogeeRadius); for (double alphaV = 0; alphaV <= 2 * FastMath.PI; alphaV += 2 * FastMath.PI / 100.) { pCirEqua = new CircularOrbit(pCirEqua.getA(), pCirEqua.getCircularEx(), pCirEqua.getCircularEy(), pCirEqua.getI(), pCirEqua.getRightAscensionOfAscendingNode(), alphaV, PositionAngle.TRUE, pCirEqua.getFrame(), date, mu); position = pCirEqua.getPVCoordinates().getPosition(); // test if the norm pf the position is in the range [perigee radius, apogee radius] Assert.assertTrue((position.getNorm() - apogeeRadius) <= (apogeeRadius * Utils.epsilonTest)); Assert.assertTrue((position.getNorm() - perigeeRadius) >= (-perigeeRadius * Utils.epsilonTest)); position = position.normalize(); velocity = pCirEqua.getPVCoordinates().getVelocity(); velocity = velocity.normalize(); // at this stage of computation, all the vectors (position, velocity and momemtum) are normalized here // test of orthogonality between position and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(position, momentum)) < Utils.epsilonTest); // test of orthogonality between velocity and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(velocity, momentum)) < Utils.epsilonTest); }/*from w ww .j a v a2 s . c om*/ }
From source file:org.orekit.orbits.EquinoctialParametersTest.java
@Test public void testGeometry() { // elliptic and non equatorial (i retrograde) orbit EquinoctialOrbit p = new EquinoctialOrbit(42166.712, 0.5, -0.5, 1.200, 2.1, 0.67, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu); Vector3D position = p.getPVCoordinates().getPosition(); Vector3D velocity = p.getPVCoordinates().getVelocity(); Vector3D momentum = p.getPVCoordinates().getMomentum().normalize(); double apogeeRadius = p.getA() * (1 + p.getE()); double perigeeRadius = p.getA() * (1 - p.getE()); for (double lv = 0; lv <= 2 * FastMath.PI; lv += 2 * FastMath.PI / 100.) { p = new EquinoctialOrbit(p.getA(), p.getEquinoctialEx(), p.getEquinoctialEy(), p.getHx(), p.getHy(), lv, PositionAngle.TRUE, p.getFrame(), p.getDate(), p.getMu()); position = p.getPVCoordinates().getPosition(); // test if the norm of the position is in the range [perigee radius, // apogee radius] // Warning: these tests are without absolute value by choice Assert.assertTrue((position.getNorm() - apogeeRadius) <= (apogeeRadius * Utils.epsilonTest)); Assert.assertTrue((position.getNorm() - perigeeRadius) >= (-perigeeRadius * Utils.epsilonTest)); position = position.normalize(); velocity = p.getPVCoordinates().getVelocity(); velocity = velocity.normalize(); // at this stage of computation, all the vectors (position, velocity and // momemtum) are normalized here // test of orthogonality between position and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(position, momentum)) < Utils.epsilonTest); // test of orthogonality between velocity and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(velocity, momentum)) < Utils.epsilonTest); }/* w w w. jav a 2 s .co m*/ // circular and equatorial orbit EquinoctialOrbit pCirEqua = new EquinoctialOrbit(42166.712, 0.1e-8, 0.1e-8, 0.1e-8, 0.1e-8, 0.67, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu); position = pCirEqua.getPVCoordinates().getPosition(); velocity = pCirEqua.getPVCoordinates().getVelocity(); momentum = Vector3D.crossProduct(position, velocity).normalize(); apogeeRadius = pCirEqua.getA() * (1 + pCirEqua.getE()); perigeeRadius = pCirEqua.getA() * (1 - pCirEqua.getE()); // test if apogee equals perigee Assert.assertEquals(perigeeRadius, apogeeRadius, 1.e+4 * Utils.epsilonTest * apogeeRadius); for (double lv = 0; lv <= 2 * FastMath.PI; lv += 2 * FastMath.PI / 100.) { pCirEqua = new EquinoctialOrbit(pCirEqua.getA(), pCirEqua.getEquinoctialEx(), pCirEqua.getEquinoctialEy(), pCirEqua.getHx(), pCirEqua.getHy(), lv, PositionAngle.TRUE, pCirEqua.getFrame(), p.getDate(), p.getMu()); position = pCirEqua.getPVCoordinates().getPosition(); // test if the norm pf the position is in the range [perigee radius, // apogee radius] Assert.assertTrue((position.getNorm() - apogeeRadius) <= (apogeeRadius * Utils.epsilonTest)); Assert.assertTrue((position.getNorm() - perigeeRadius) >= (-perigeeRadius * Utils.epsilonTest)); position = position.normalize(); velocity = pCirEqua.getPVCoordinates().getVelocity(); velocity = velocity.normalize(); // at this stage of computation, all the vectors (position, velocity and // momemtum) are normalized here // test of orthogonality between position and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(position, momentum)) < Utils.epsilonTest); // test of orthogonality between velocity and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(velocity, momentum)) < Utils.epsilonTest); } }
From source file:org.orekit.orbits.KeplerianParametersTest.java
@Test public void testGeometry() { double mu = 3.9860047e14; // elliptic and non equatorial orbit KeplerianOrbit p = new KeplerianOrbit(24464560.0, 0.7311, 2.1, 3.10686, 1.00681, 0.67, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu); Vector3D position = p.getPVCoordinates().getPosition(); Vector3D velocity = p.getPVCoordinates().getVelocity(); Vector3D momentum = p.getPVCoordinates().getMomentum().normalize(); double apogeeRadius = p.getA() * (1 + p.getE()); double perigeeRadius = p.getA() * (1 - p.getE()); for (double lv = 0; lv <= 2 * FastMath.PI; lv += 2 * FastMath.PI / 100.) { p = new KeplerianOrbit(p.getA(), p.getE(), p.getI(), p.getPerigeeArgument(), p.getRightAscensionOfAscendingNode(), lv, PositionAngle.TRUE, p.getFrame(), p.getDate(), p.getMu());//from www . j av a2 s. c o m position = p.getPVCoordinates().getPosition(); // test if the norm of the position is in the range [perigee radius, apogee radius] Assert.assertTrue((position.getNorm() - apogeeRadius) <= (apogeeRadius * Utils.epsilonTest)); Assert.assertTrue((position.getNorm() - perigeeRadius) >= (-perigeeRadius * Utils.epsilonTest)); position = position.normalize(); velocity = p.getPVCoordinates().getVelocity(); velocity = velocity.normalize(); // at this stage of computation, all the vectors (position, velocity and momemtum) are normalized here // test of orthogonality between position and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(position, momentum)) < Utils.epsilonTest); // test of orthogonality between velocity and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(velocity, momentum)) < Utils.epsilonTest); } // apsides p = new KeplerianOrbit(p.getA(), p.getE(), p.getI(), p.getPerigeeArgument(), p.getRightAscensionOfAscendingNode(), 0, PositionAngle.TRUE, p.getFrame(), p.getDate(), p.getMu()); Assert.assertEquals(p.getPVCoordinates().getPosition().getNorm(), perigeeRadius, perigeeRadius * Utils.epsilonTest); p = new KeplerianOrbit(p.getA(), p.getE(), p.getI(), p.getPerigeeArgument(), p.getRightAscensionOfAscendingNode(), FastMath.PI, PositionAngle.TRUE, p.getFrame(), p.getDate(), p.getMu()); Assert.assertEquals(p.getPVCoordinates().getPosition().getNorm(), apogeeRadius, apogeeRadius * Utils.epsilonTest); // nodes // descending node p = new KeplerianOrbit(p.getA(), p.getE(), p.getI(), p.getPerigeeArgument(), p.getRightAscensionOfAscendingNode(), FastMath.PI - p.getPerigeeArgument(), PositionAngle.TRUE, p.getFrame(), p.getDate(), p.getMu()); Assert.assertTrue(FastMath .abs(p.getPVCoordinates().getPosition().getZ()) < p.getPVCoordinates().getPosition().getNorm() * Utils.epsilonTest); Assert.assertTrue(p.getPVCoordinates().getVelocity().getZ() < 0); // ascending node p = new KeplerianOrbit(p.getA(), p.getE(), p.getI(), p.getPerigeeArgument(), p.getRightAscensionOfAscendingNode(), 2.0 * FastMath.PI - p.getPerigeeArgument(), PositionAngle.TRUE, p.getFrame(), p.getDate(), p.getMu()); Assert.assertTrue(FastMath .abs(p.getPVCoordinates().getPosition().getZ()) < p.getPVCoordinates().getPosition().getNorm() * Utils.epsilonTest); Assert.assertTrue(p.getPVCoordinates().getVelocity().getZ() > 0); // circular and equatorial orbit KeplerianOrbit pCirEqua = new KeplerianOrbit(24464560.0, 0.1e-10, 0.1e-8, 3.10686, 1.00681, 0.67, PositionAngle.TRUE, FramesFactory.getEME2000(), date, mu); position = pCirEqua.getPVCoordinates().getPosition(); velocity = pCirEqua.getPVCoordinates().getVelocity(); momentum = Vector3D.crossProduct(position, velocity).normalize(); apogeeRadius = pCirEqua.getA() * (1 + pCirEqua.getE()); perigeeRadius = pCirEqua.getA() * (1 - pCirEqua.getE()); // test if apogee equals perigee Assert.assertEquals(perigeeRadius, apogeeRadius, 1.e+4 * Utils.epsilonTest * apogeeRadius); for (double lv = 0; lv <= 2 * FastMath.PI; lv += 2 * FastMath.PI / 100.) { pCirEqua = new KeplerianOrbit(pCirEqua.getA(), pCirEqua.getE(), pCirEqua.getI(), pCirEqua.getPerigeeArgument(), pCirEqua.getRightAscensionOfAscendingNode(), lv, PositionAngle.TRUE, pCirEqua.getFrame(), pCirEqua.getDate(), pCirEqua.getMu()); position = pCirEqua.getPVCoordinates().getPosition(); // test if the norm pf the position is in the range [perigee radius, apogee radius] // Warning: these tests are without absolute value by choice Assert.assertTrue((position.getNorm() - apogeeRadius) <= (apogeeRadius * Utils.epsilonTest)); Assert.assertTrue((position.getNorm() - perigeeRadius) >= (-perigeeRadius * Utils.epsilonTest)); position = position.normalize(); velocity = pCirEqua.getPVCoordinates().getVelocity(); velocity = velocity.normalize(); // at this stage of computation, all the vectors (position, velocity and momemtum) are normalized here // test of orthogonality between position and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(position, momentum)) < Utils.epsilonTest); // test of orthogonality between velocity and momentum Assert.assertTrue(FastMath.abs(Vector3D.dotProduct(velocity, momentum)) < Utils.epsilonTest); } }
From source file:org.orekit.orbits.KeplerianParametersTest.java
@Test public void testHyperbola() { KeplerianOrbit orbit = new KeplerianOrbit(-10000000.0, 2.5, 0.3, 0, 0, 0.0, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, mu); Vector3D perigeeP = orbit.getPVCoordinates().getPosition(); Vector3D u = perigeeP.normalize(); Vector3D focus1 = Vector3D.ZERO; Vector3D focus2 = new Vector3D(-2 * orbit.getA() * orbit.getE(), u); for (double dt = -5000; dt < 5000; dt += 60) { PVCoordinates pv = orbit.shiftedBy(dt).getPVCoordinates(); double d1 = Vector3D.distance(pv.getPosition(), focus1); double d2 = Vector3D.distance(pv.getPosition(), focus2); Assert.assertEquals(-2 * orbit.getA(), FastMath.abs(d1 - d2), 1.0e-6); KeplerianOrbit rebuilt = new KeplerianOrbit(pv, orbit.getFrame(), orbit.getDate().shiftedBy(dt), mu); Assert.assertEquals(-10000000.0, rebuilt.getA(), 1.0e-6); Assert.assertEquals(2.5, rebuilt.getE(), 1.0e-13); }//from w w w. j a va 2 s. c o m }