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.bodies.OneAxisEllipsoid.java
/** {@inheritDoc} */ public Vector3D projectToGround(final Vector3D point, final AbsoluteDate date, final Frame frame) throws OrekitException { // transform point to body frame final Transform toBody = frame.getTransformTo(bodyFrame, date); final Vector3D p = toBody.transformPosition(point); final double z = p.getZ(); final double r = FastMath.hypot(p.getX(), p.getY()); // set up the 2D meridian ellipse final Ellipse meridian = new Ellipse(Vector3D.ZERO, new Vector3D(p.getX() / r, p.getY() / r, 0), Vector3D.PLUS_K, getA(), getC(), bodyFrame); // find the closest point in the meridian plane final Vector3D groundPoint = meridian.toSpace(meridian.projectToEllipse(new Vector2D(r, z))); // transform point back to initial frame return toBody.getInverse().transformPosition(groundPoint); }
From source file:org.orekit.bodies.OneAxisEllipsoid.java
/** {@inheritDoc} */ public TimeStampedPVCoordinates projectToGround(final TimeStampedPVCoordinates pv, final Frame frame) throws OrekitException { // transform point to body frame final Transform toBody = frame.getTransformTo(bodyFrame, pv.getDate()); final TimeStampedPVCoordinates pvInBodyFrame = toBody.transformPVCoordinates(pv); final Vector3D p = pvInBodyFrame.getPosition(); final double r = FastMath.hypot(p.getX(), p.getY()); // set up the 2D ellipse corresponding to first principal curvature along meridian final Vector3D meridian = new Vector3D(p.getX() / r, p.getY() / r, 0); final Ellipse firstPrincipalCurvature = new Ellipse(Vector3D.ZERO, meridian, Vector3D.PLUS_K, getA(), getC(), bodyFrame);/* w w w.jav a 2 s .c om*/ // project coordinates in the meridian plane final TimeStampedPVCoordinates gpFirst = firstPrincipalCurvature.projectToEllipse(pvInBodyFrame); final Vector3D gpP = gpFirst.getPosition(); final double gr = MathArrays.linearCombination(gpP.getX(), meridian.getX(), gpP.getY(), meridian.getY()); final double gz = gpP.getZ(); // topocentric frame final Vector3D east = new Vector3D(-meridian.getY(), meridian.getX(), 0); final Vector3D zenith = new Vector3D(gr * getC() / getA(), meridian, gz * getA() / getC(), Vector3D.PLUS_K) .normalize(); final Vector3D north = Vector3D.crossProduct(zenith, east); // set up the ellipse corresponding to second principal curvature in the zenith/east plane final Ellipse secondPrincipalCurvature = getPlaneSection(gpP, north); final TimeStampedPVCoordinates gpSecond = secondPrincipalCurvature.projectToEllipse(pvInBodyFrame); final Vector3D gpV = gpFirst.getVelocity().add(gpSecond.getVelocity()); final Vector3D gpA = gpFirst.getAcceleration().add(gpSecond.getAcceleration()); // moving projected point final TimeStampedPVCoordinates groundPV = new TimeStampedPVCoordinates(pv.getDate(), gpP, gpV, gpA); // transform moving projected point back to initial frame return toBody.getInverse().transformPVCoordinates(groundPV); }
From source file:org.orekit.bodies.OneAxisEllipsoid.java
/** {@inheritDoc} */ public GeodeticPoint transform(final Vector3D point, final Frame frame, final AbsoluteDate date) throws OrekitException { // transform point to body frame final Vector3D pointInBodyFrame = frame.getTransformTo(bodyFrame, date).transformPosition(point); final double r2 = pointInBodyFrame.getX() * pointInBodyFrame.getX() + pointInBodyFrame.getY() * pointInBodyFrame.getY(); final double r = FastMath.sqrt(r2); final double z = pointInBodyFrame.getZ(); // set up the 2D meridian ellipse final Ellipse meridian = new Ellipse(Vector3D.ZERO, new Vector3D(pointInBodyFrame.getX() / r, pointInBodyFrame.getY() / r, 0), Vector3D.PLUS_K, getA(), getC(), bodyFrame);/*w ww . ja va2s.c om*/ // project point on the 2D meridian ellipse final Vector2D ellipsePoint = meridian.projectToEllipse(new Vector2D(r, z)); // relative position of test point with respect to its ellipse sub-point final double dr = r - ellipsePoint.getX(); final double dz = z - ellipsePoint.getY(); final double insideIfNegative = g2 * (r2 - ae2) + z * z; return new GeodeticPoint(FastMath.atan2(ellipsePoint.getY(), g2 * ellipsePoint.getX()), FastMath.atan2(pointInBodyFrame.getY(), pointInBodyFrame.getX()), FastMath.copySign(FastMath.hypot(dr, dz), insideIfNegative)); }
From source file:org.orekit.bodies.OneAxisEllipsoidTest.java
@Test public void testOnSurface() throws OrekitException { Vector3D surfacePoint = new Vector3D(-1092200.775949484, -3944945.7282234835, 4874931.946956173); OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, FramesFactory.getITRF(IERSConventions.IERS_2010, true)); GeodeticPoint gp = earthShape.transform(surfacePoint, earthShape.getBodyFrame(), AbsoluteDate.J2000_EPOCH); Vector3D rebuilt = earthShape.transform(gp); Assert.assertEquals(0, rebuilt.distance(surfacePoint), 3.0e-9); }
From source file:org.orekit.bodies.OneAxisEllipsoidTest.java
@Test public void testGroundProjectionPosition() throws OrekitException { OneAxisEllipsoid model = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true)); TimeStampedPVCoordinates initPV = new TimeStampedPVCoordinates(AbsoluteDate.J2000_EPOCH.shiftedBy(584.), new Vector3D(3220103., 69623., 6449822.), new Vector3D(6414.7, -2006., -3180.), Vector3D.ZERO); Frame eme2000 = FramesFactory.getEME2000(); Orbit orbit = new EquinoctialOrbit(initPV, eme2000, Constants.EIGEN5C_EARTH_MU); for (double dt = 0; dt < 3600.0; dt += 60.0) { TimeStampedPVCoordinates pv = orbit.getPVCoordinates(orbit.getDate().shiftedBy(dt), eme2000); TimeStampedPVCoordinates groundPV = model.projectToGround(pv, eme2000); Vector3D groundP = model.projectToGround(pv.getPosition(), pv.getDate(), eme2000); // check methods projectToGround and transform are consistent with each other Assert.assertEquals(model.transform(pv.getPosition(), eme2000, pv.getDate()).getLatitude(), model.transform(groundPV.getPosition(), eme2000, pv.getDate()).getLatitude(), 1.0e-10); Assert.assertEquals(model.transform(pv.getPosition(), eme2000, pv.getDate()).getLongitude(), model.transform(groundPV.getPosition(), eme2000, pv.getDate()).getLongitude(), 1.0e-10); Assert.assertEquals(0.0, Vector3D.distance(groundP, groundPV.getPosition()), 1.0e-15 * groundP.getNorm()); }/*from ww w . j av a2s .c o m*/ }
From source file:org.orekit.bodies.OneAxisEllipsoidTest.java
@Test public void testGroundProjectionDerivatives() throws OrekitException { Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true); Frame eme2000 = FramesFactory.getEME2000(); OneAxisEllipsoid model = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, itrf); TimeStampedPVCoordinates initPV = new TimeStampedPVCoordinates(AbsoluteDate.J2000_EPOCH.shiftedBy(584.), new Vector3D(3220103., 69623., 6449822.), new Vector3D(6414.7, -2006., -3180.), Vector3D.ZERO); Orbit orbit = new EquinoctialOrbit(initPV, eme2000, Constants.EIGEN5C_EARTH_MU); double[] errors = derivativesErrors(orbit, orbit.getDate(), eme2000, model); Assert.assertEquals(0, errors[0], 1.0e-16); Assert.assertEquals(0, errors[1], 2.0e-12); Assert.assertEquals(0, errors[2], 2.0e-4); }
From source file:org.orekit.bodies.OneAxisEllipsoidTest.java
@Test public void testGroundToGroundIssue181() throws OrekitException { Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true); Frame eme2000 = FramesFactory.getEME2000(); OneAxisEllipsoid model = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, itrf); TimeStampedPVCoordinates initPV = new TimeStampedPVCoordinates(AbsoluteDate.J2000_EPOCH.shiftedBy(584.), new Vector3D(3220103., 69623., 6449822.), new Vector3D(6414.7, -2006., -3180.), Vector3D.ZERO); TimeStampedPVCoordinates body = itrf.getTransformTo(eme2000, initPV.getDate()) .transformPVCoordinates(initPV); TimeStampedPVCoordinates ground1 = model.projectToGround(body, itrf); TimeStampedPVCoordinates ground2 = model.projectToGround(ground1, itrf); Assert.assertEquals(0.0, Vector3D.distance(ground1.getPosition(), ground2.getPosition()), 1.0e-12); Assert.assertEquals(0.0, Vector3D.distance(ground1.getVelocity(), ground2.getVelocity()), 2.0e-12); Assert.assertEquals(0.0, Vector3D.distance(ground1.getAcceleration(), ground2.getAcceleration()), 1.0e-12); }
From source file:org.orekit.bodies.OneAxisEllipsoidTest.java
@Test public void testGroundProjectionTaylor() throws OrekitException { Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true); Frame eme2000 = FramesFactory.getEME2000(); OneAxisEllipsoid model = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, itrf); TimeStampedPVCoordinates initPV = new TimeStampedPVCoordinates(AbsoluteDate.J2000_EPOCH.shiftedBy(584.), new Vector3D(3220103., 69623., 6449822.), new Vector3D(6414.7, -2006., -3180.), Vector3D.ZERO); Orbit orbit = new EquinoctialOrbit(initPV, eme2000, Constants.EIGEN5C_EARTH_MU); TimeStampedPVCoordinates pv0 = orbit.getPVCoordinates(orbit.getDate(), model.getBodyFrame()); PVCoordinatesProvider groundTaylor = model.projectToGround(pv0, model.getBodyFrame()) .toTaylorProvider(model.getBodyFrame()); TimeStampedPVCoordinates g0 = groundTaylor.getPVCoordinates(orbit.getDate(), model.getBodyFrame()); Vector3D zenith = pv0.getPosition().subtract(g0.getPosition()).normalize(); Vector3D acrossTrack = Vector3D.crossProduct(zenith, g0.getVelocity()).normalize(); Vector3D alongTrack = Vector3D.crossProduct(acrossTrack, zenith).normalize(); for (double dt = -1; dt < 1; dt += 0.01) { AbsoluteDate date = orbit.getDate().shiftedBy(dt); Vector3D taylorP = groundTaylor.getPVCoordinates(date, model.getBodyFrame()).getPosition(); Vector3D refP = model.projectToGround(orbit.getPVCoordinates(date, model.getBodyFrame()).getPosition(), date, model.getBodyFrame()); Vector3D delta = taylorP.subtract(refP); Assert.assertEquals(0.0, Vector3D.dotProduct(delta, alongTrack), 0.0015); Assert.assertEquals(0.0, Vector3D.dotProduct(delta, acrossTrack), 0.0007); Assert.assertEquals(0.0, Vector3D.dotProduct(delta, zenith), 0.00002); }// ww w. j a v a 2 s . c om }
From source file:org.orekit.bodies.OneAxisEllipsoidTest.java
@Test public void testLineIntersection() throws OrekitException { AbsoluteDate date = AbsoluteDate.J2000_EPOCH; Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2010, true); OneAxisEllipsoid model = new OneAxisEllipsoid(100.0, 0.9, frame); Vector3D point = new Vector3D(0.0, 93.7139699, 3.5930796); Vector3D direction = new Vector3D(0.0, 1.0, 1.0); Line line = new Line(point, point.add(direction), 1.0e-10); GeodeticPoint gp = model.getIntersectionPoint(line, point, frame, date); Assert.assertEquals(gp.getAltitude(), 0.0, 1.0e-12); Assert.assertTrue(line.contains(model.transform(gp))); model = new OneAxisEllipsoid(100.0, 0.9, frame); point = new Vector3D(0.0, -93.7139699, -3.5930796); direction = new Vector3D(0.0, -1.0, -1.0); line = new Line(point, point.add(direction), 1.0e-10).revert(); gp = model.getIntersectionPoint(line, point, frame, date); Assert.assertTrue(line.contains(model.transform(gp))); model = new OneAxisEllipsoid(100.0, 0.9, frame); point = new Vector3D(0.0, -93.7139699, 3.5930796); direction = new Vector3D(0.0, -1.0, 1.0); line = new Line(point, point.add(direction), 1.0e-10); gp = model.getIntersectionPoint(line, point, frame, date); Assert.assertTrue(line.contains(model.transform(gp))); model = new OneAxisEllipsoid(100.0, 0.9, frame); point = new Vector3D(-93.7139699, 0.0, 3.5930796); direction = new Vector3D(-1.0, 0.0, 1.0); line = new Line(point, point.add(direction), 1.0e-10); gp = model.getIntersectionPoint(line, point, frame, date); Assert.assertTrue(line.contains(model.transform(gp))); Assert.assertFalse(line.contains(new Vector3D(0, 0, 7000000))); point = new Vector3D(0.0, 0.0, 110); direction = new Vector3D(0.0, 0.0, 1.0); line = new Line(point, point.add(direction), 1.0e-10); gp = model.getIntersectionPoint(line, point, frame, date); Assert.assertEquals(gp.getLatitude(), FastMath.PI / 2, 1.0e-12); point = new Vector3D(0.0, 110, 0); direction = new Vector3D(0.0, 1.0, 0.0); line = new Line(point, point.add(direction), 1.0e-10); gp = model.getIntersectionPoint(line, point, frame, date); Assert.assertEquals(gp.getLatitude(), 0, 1.0e-12); }
From source file:org.orekit.bodies.OneAxisEllipsoidTest.java
@Test public void testNoLineIntersection() throws OrekitException { AbsoluteDate date = AbsoluteDate.J2000_EPOCH; Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2010, true); OneAxisEllipsoid model = new OneAxisEllipsoid(100.0, 0.9, frame); Vector3D point = new Vector3D(0.0, 93.7139699, 3.5930796); Vector3D direction = new Vector3D(0.0, 9.0, -2.0); Line line = new Line(point, point.add(direction), 1.0e-10); Assert.assertNull(model.getIntersectionPoint(line, point, frame, date)); }