List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D getNorm
public double getNorm()
From source file:org.orekit.frames.HelmertTransformationTest.java
@Test public void testHelmert19932000() throws OrekitException { Frame itrf2008 = FramesFactory.getITRF(IERSConventions.IERS_2010, true); Frame itrf2000 = HelmertTransformation.Predefined.ITRF_2008_TO_ITRF_2000.createTransformedITRF(itrf2008, "2000"); Frame itrf93 = HelmertTransformation.Predefined.ITRF_2008_TO_ITRF_93.createTransformedITRF(itrf2008, "93"); Vector3D pos93 = new Vector3D(1234567.8, 2345678.9, 3456789.0); // check the Helmert transformation as per ftp://itrf.ensg.ign.fr/pub/itrf/ITRF.TP AbsoluteDate date = new AbsoluteDate(1988, 1, 1, 12, 0, 0, TimeScalesFactory.getTT()); Vector3D pos2000 = itrf93.getTransformTo(itrf2000, date).transformPosition(pos93); Vector3D generalOffset = pos93.subtract(pos2000); Vector3D linearOffset = computeOffsetLinearly(12.7, 6.5, -20.9, -0.39, 0.80, -1.14, -2.9, -0.2, -0.6, -0.11, -0.19, 0.07, pos2000, 0.0);// w w w .j a v a 2 s. c o m Vector3D error = generalOffset.subtract(linearOffset); Assert.assertEquals(0.0, error.getNorm(), FastMath.ulp(pos93.getNorm())); date = date.shiftedBy(Constants.JULIAN_YEAR); pos2000 = itrf93.getTransformTo(itrf2000, date).transformPosition(pos93); generalOffset = pos93.subtract(pos2000); linearOffset = computeOffsetLinearly(12.7, 6.5, -20.9, -0.39, 0.80, -1.14, -2.9, -0.2, -0.6, -0.11, -0.19, 0.07, pos2000, 1.0); error = generalOffset.subtract(linearOffset); Assert.assertEquals(0.0, error.getNorm(), FastMath.ulp(pos93.getNorm())); }
From source file:org.orekit.frames.LocalOrbitalFrameTest.java
private void checkFrame(LOFType type, AbsoluteDate date, Vector3D expectedXDirection, Vector3D expectedYDirection, Vector3D expectedZDirection, Vector3D expectedRotationDirection) throws OrekitException { LocalOrbitalFrame lof = new LocalOrbitalFrame(FramesFactory.getGCRF(), type, provider, type.name()); Transform t = lof.getTransformTo(FramesFactory.getGCRF(), date); PVCoordinates pv1 = t.transformPVCoordinates(PVCoordinates.ZERO); Vector3D p1 = pv1.getPosition(); Vector3D v1 = pv1.getVelocity(); PVCoordinates pv2 = provider.getPVCoordinates(date, FramesFactory.getGCRF()); Vector3D p2 = pv2.getPosition(); Vector3D v2 = pv2.getVelocity(); Assert.assertEquals(0, p1.subtract(p2).getNorm(), 1.0e-14 * p1.getNorm()); Assert.assertEquals(0, v1.subtract(v2).getNorm(), 1.0e-14 * v1.getNorm()); Vector3D xDirection = t.transformVector(Vector3D.PLUS_I); Vector3D yDirection = t.transformVector(Vector3D.PLUS_J); Vector3D zDirection = t.transformVector(Vector3D.PLUS_K); Assert.assertEquals(0, Vector3D.angle(expectedXDirection, xDirection), 2.0e-15); Assert.assertEquals(0, Vector3D.angle(expectedYDirection, yDirection), 1.0e-15); Assert.assertEquals(0, Vector3D.angle(expectedZDirection, zDirection), 1.0e-15); Assert.assertEquals(0, Vector3D.angle(expectedRotationDirection, t.getRotationRate()), 1.0e-15); Assert.assertEquals(initialOrbit.getKeplerianMeanMotion(), t.getRotationRate().getNorm(), 1.0e-7); }
From source file:org.orekit.frames.SpacecraftFrameTest.java
@Test public void testYawSteering() throws OrekitException { AbsoluteDate stopDate = iniDate.shiftedBy(3000.0); Vector3D sunSat = sun.getPVCoordinates(stopDate, scFrame).getPosition(); Assert.assertEquals(0, (sunSat.getY() / sunSat.getNorm()), Utils.epsilonTest); }
From source file:org.orekit.frames.TopocentricFrame.java
/** Get the range of a point with regards to the topocentric frame center point. * @param extPoint point for which range shall be computed * @param frame frame in which the point is defined * @param date computation date//from w w w . j a va2s . co m * @return range (distance) of the point * @exception OrekitException if frames transformations cannot be computed */ public double getRange(final Vector3D extPoint, final Frame frame, final AbsoluteDate date) throws OrekitException { // Transform given point from given frame to topocentric frame final Transform t = frame.getTransformTo(this, date); final Vector3D extPointTopo = t.transformPosition(extPoint); // Compute range return extPointTopo.getNorm(); }
From source file:org.orekit.frames.TransformTest.java
@Test public void testLinear() { RandomGenerator random = new Well19937a(0x14f6411217b148d8l); for (int n = 0; n < 100; ++n) { Transform t = randomTransform(random); // build an equivalent linear transform by extracting raw translation/rotation RealMatrix linearA = MatrixUtils.createRealMatrix(3, 4); linearA.setSubMatrix(t.getRotation().getMatrix(), 0, 0); Vector3D rt = t.getRotation().applyTo(t.getTranslation()); linearA.setEntry(0, 3, rt.getX()); linearA.setEntry(1, 3, rt.getY()); linearA.setEntry(2, 3, rt.getZ()); // build an equivalent linear transform by observing transformed points RealMatrix linearB = MatrixUtils.createRealMatrix(3, 4); Vector3D p0 = t.transformPosition(Vector3D.ZERO); Vector3D pI = t.transformPosition(Vector3D.PLUS_I).subtract(p0); Vector3D pJ = t.transformPosition(Vector3D.PLUS_J).subtract(p0); Vector3D pK = t.transformPosition(Vector3D.PLUS_K).subtract(p0); linearB.setColumn(0, new double[] { pI.getX(), pI.getY(), pI.getZ() }); linearB.setColumn(1, new double[] { pJ.getX(), pJ.getY(), pJ.getZ() }); linearB.setColumn(2, new double[] { pK.getX(), pK.getY(), pK.getZ() }); linearB.setColumn(3, new double[] { p0.getX(), p0.getY(), p0.getZ() }); // both linear transforms should be equal Assert.assertEquals(0.0, linearB.subtract(linearA).getNorm(), 1.0e-15 * linearA.getNorm()); for (int i = 0; i < 100; ++i) { Vector3D p = randomVector(1.0e3, random); Vector3D q = t.transformPosition(p); double[] qA = linearA.operate(new double[] { p.getX(), p.getY(), p.getZ(), 1.0 }); Assert.assertEquals(q.getX(), qA[0], 1.0e-13 * p.getNorm()); Assert.assertEquals(q.getY(), qA[1], 1.0e-13 * p.getNorm()); Assert.assertEquals(q.getZ(), qA[2], 1.0e-13 * p.getNorm()); double[] qB = linearB.operate(new double[] { p.getX(), p.getY(), p.getZ(), 1.0 }); Assert.assertEquals(q.getX(), qB[0], 1.0e-10 * p.getNorm()); Assert.assertEquals(q.getY(), qB[1], 1.0e-10 * p.getNorm()); Assert.assertEquals(q.getZ(), qB[2], 1.0e-10 * p.getNorm()); }//from w w w . j ava 2s . c o m } }
From source file:org.orekit.frames.TransformTest.java
private void checkNoTransform(Transform transform, RandomGenerator random) { for (int i = 0; i < 100; ++i) { Vector3D a = randomVector(1.0e3, random); Vector3D tA = transform.transformVector(a); Assert.assertEquals(0, a.subtract(tA).getNorm(), 1.0e-10 * a.getNorm()); Vector3D b = randomVector(1.0e3, random); Vector3D tB = transform.transformPosition(b); Assert.assertEquals(0, b.subtract(tB).getNorm(), 1.0e-10 * a.getNorm()); PVCoordinates pv = new PVCoordinates(randomVector(1.0e3, random), randomVector(1.0, random), randomVector(1.0e-3, random)); PVCoordinates tPv = transform.transformPVCoordinates(pv); checkVector(pv.getPosition(), tPv.getPosition(), 1.0e-10); checkVector(pv.getVelocity(), tPv.getVelocity(), 3.0e-9); checkVector(pv.getAcceleration(), tPv.getAcceleration(), 3.0e-9); }/*from w w w .j a v a 2 s.c o m*/ }
From source file:org.orekit.frames.TransformTest.java
private void checkVector(Vector3D reference, Vector3D result, double relativeTolerance) { double refNorm = reference.getNorm(); double resNorm = result.getNorm(); double tolerance = relativeTolerance * (1 + FastMath.max(refNorm, resNorm)); Assert.assertEquals(/*from w ww . j a v a2 s . co m*/ "ref = " + reference + ", res = " + result + " -> " + (Vector3D.distance(reference, result) / (1 + FastMath.max(refNorm, resNorm))), 0, Vector3D.distance(reference, result), tolerance); }
From source file:org.orekit.models.earth.GeoMagneticElements.java
/** Construct a new element with the given field vector. The other elements * of the magnetic field are calculated from the field vector. * @param b the magnetic field vector//from ww w . jav a 2 s . co m */ public GeoMagneticElements(final Vector3D b) { this.b = b; horizontalIntensity = FastMath.hypot(b.getX(), b.getY()); totalIntensity = b.getNorm(); declination = FastMath.toDegrees(FastMath.atan2(b.getY(), b.getX())); inclination = FastMath.toDegrees(FastMath.atan2(b.getZ(), horizontalIntensity)); }
From source file:org.orekit.models.earth.tessellation.AlongTrackAimingTest.java
@Test public void testAscending() throws OrekitException { final AlongTrackAiming tileAiming = new AlongTrackAiming(ellipsoid, orbit, true); for (double latitude = FastMath.toRadians(-50.21); latitude < FastMath .toRadians(50.21); latitude += 0.001) { final GeodeticPoint gp = new GeodeticPoint(latitude, 0.0, 0.0); final Vector3D aiming = tileAiming.alongTileDirection(ellipsoid.transform(gp), gp); Assert.assertEquals(1.0, aiming.getNorm(), 1.0e-12); final double elevation = 0.5 * FastMath.PI - Vector3D.angle(aiming, gp.getZenith()); final double azimuth = FastMath.atan2(Vector3D.dotProduct(aiming, gp.getEast()), Vector3D.dotProduct(aiming, gp.getNorth())); Assert.assertEquals(0.0, FastMath.toDegrees(elevation), 1.0e-6); if (FastMath.abs(FastMath.toDegrees(latitude)) > 49.6) { Assert.assertTrue(FastMath.toDegrees(azimuth) > 80.0); }/* w ww. j av a 2 s. c o m*/ if (FastMath.abs(FastMath.toDegrees(latitude)) < 5.0) { Assert.assertTrue(FastMath.toDegrees(azimuth) < 37.0); } Assert.assertTrue(FastMath.toDegrees(azimuth) > 36.7); } }
From source file:org.orekit.models.earth.tessellation.AlongTrackAimingTest.java
@Test public void testDescending() throws OrekitException { final AlongTrackAiming tileAiming = new AlongTrackAiming(ellipsoid, orbit, false); for (double latitude = FastMath.toRadians(-50.21); latitude < FastMath .toRadians(50.21); latitude += 0.001) { final GeodeticPoint gp = new GeodeticPoint(latitude, 0.0, 0.0); final Vector3D aiming = tileAiming.alongTileDirection(ellipsoid.transform(gp), gp); Assert.assertEquals(1.0, aiming.getNorm(), 1.0e-12); final double elevation = 0.5 * FastMath.PI - Vector3D.angle(aiming, gp.getZenith()); final double azimuth = MathUtils.normalizeAngle(FastMath .atan2(Vector3D.dotProduct(aiming, gp.getEast()), Vector3D.dotProduct(aiming, gp.getNorth())), FastMath.PI);//w ww .j ava 2 s .c o m Assert.assertEquals(0.0, FastMath.toDegrees(elevation), 1.0e-6); if (FastMath.abs(FastMath.toDegrees(latitude)) > 49.7) { Assert.assertTrue(FastMath.toDegrees(azimuth) < 99.0); } if (FastMath.abs(FastMath.toDegrees(latitude)) < 5.0) { Assert.assertTrue(FastMath.toDegrees(azimuth) > 143); } Assert.assertTrue(FastMath.toDegrees(azimuth) < 143.3); } }