List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D getX
public double getX()
From source file:org.orekit.utils.TimeStampedPVCoordinatesTest.java
@Test public void testToDerivativeStructureVector2() throws OrekitException { FieldVector3D<DerivativeStructure> fv = new TimeStampedPVCoordinates(AbsoluteDate.GALILEO_EPOCH, new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)) .toDerivativeStructureVector(2); Assert.assertEquals(1, fv.getX().getFreeParameters()); Assert.assertEquals(2, fv.getX().getOrder()); Assert.assertEquals(1.0, fv.getX().getReal(), 1.0e-10); Assert.assertEquals(0.1, fv.getY().getReal(), 1.0e-10); Assert.assertEquals(10.0, fv.getZ().getReal(), 1.0e-10); Assert.assertEquals(-1.0, fv.getX().getPartialDerivative(1), 1.0e-15); Assert.assertEquals(-0.1, fv.getY().getPartialDerivative(1), 1.0e-15); Assert.assertEquals(-10.0, fv.getZ().getPartialDerivative(1), 1.0e-15); Assert.assertEquals(10.0, fv.getX().getPartialDerivative(2), 1.0e-15); Assert.assertEquals(-1.0, fv.getY().getPartialDerivative(2), 1.0e-15); Assert.assertEquals(-100.0, fv.getZ().getPartialDerivative(2), 1.0e-15); checkPV(new TimeStampedPVCoordinates(AbsoluteDate.GALILEO_EPOCH, new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)), new TimeStampedPVCoordinates(AbsoluteDate.GALILEO_EPOCH, fv), 1.0e-15); for (double dt = 0; dt < 10; dt += 0.125) { Vector3D p = new PVCoordinates(new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)).shiftedBy(dt).getPosition(); Assert.assertEquals(p.getX(), fv.getX().taylor(dt), 1.0e-14); Assert.assertEquals(p.getY(), fv.getY().taylor(dt), 1.0e-14); Assert.assertEquals(p.getZ(), fv.getZ().taylor(dt), 1.0e-14); }//from w w w . j ava 2 s . co m }
From source file:org.orekit.utils.TimeStampedPVCoordinatesTest.java
@Test public void testInterpolatePolynomialPVA() { Random random = new Random(0xfe3945fcb8bf47cel); AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH; for (int i = 0; i < 20; ++i) { PolynomialFunction px = randomPolynomial(5, random); PolynomialFunction py = randomPolynomial(5, random); PolynomialFunction pz = randomPolynomial(5, random); PolynomialFunction pxDot = px.polynomialDerivative(); PolynomialFunction pyDot = py.polynomialDerivative(); PolynomialFunction pzDot = pz.polynomialDerivative(); PolynomialFunction pxDotDot = pxDot.polynomialDerivative(); PolynomialFunction pyDotDot = pyDot.polynomialDerivative(); PolynomialFunction pzDotDot = pzDot.polynomialDerivative(); List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>(); for (double dt : new double[] { 0.0, 0.5, 1.0 }) { Vector3D position = new Vector3D(px.value(dt), py.value(dt), pz.value(dt)); Vector3D velocity = new Vector3D(pxDot.value(dt), pyDot.value(dt), pzDot.value(dt)); Vector3D acceleration = new Vector3D(pxDotDot.value(dt), pyDotDot.value(dt), pzDotDot.value(dt)); sample.add(new TimeStampedPVCoordinates(t0.shiftedBy(dt), position, velocity, acceleration)); }/* ww w . j a v a 2 s .c om*/ for (double dt = 0; dt < 1.0; dt += 0.01) { TimeStampedPVCoordinates interpolated = TimeStampedPVCoordinates.interpolate(t0.shiftedBy(dt), CartesianDerivativesFilter.USE_PVA, sample); Vector3D p = interpolated.getPosition(); Vector3D v = interpolated.getVelocity(); Vector3D a = interpolated.getAcceleration(); Assert.assertEquals(px.value(dt), p.getX(), 4.0e-16 * p.getNorm()); Assert.assertEquals(py.value(dt), p.getY(), 4.0e-16 * p.getNorm()); Assert.assertEquals(pz.value(dt), p.getZ(), 4.0e-16 * p.getNorm()); Assert.assertEquals(pxDot.value(dt), v.getX(), 9.0e-16 * v.getNorm()); Assert.assertEquals(pyDot.value(dt), v.getY(), 9.0e-16 * v.getNorm()); Assert.assertEquals(pzDot.value(dt), v.getZ(), 9.0e-16 * v.getNorm()); Assert.assertEquals(pxDotDot.value(dt), a.getX(), 9.0e-15 * a.getNorm()); Assert.assertEquals(pyDotDot.value(dt), a.getY(), 9.0e-15 * a.getNorm()); Assert.assertEquals(pzDotDot.value(dt), a.getZ(), 9.0e-15 * a.getNorm()); } } }
From source file:org.orekit.utils.TimeStampedPVCoordinatesTest.java
@Test public void testInterpolatePolynomialPV() { Random random = new Random(0xae7771c9933407bdl); AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH; for (int i = 0; i < 20; ++i) { PolynomialFunction px = randomPolynomial(5, random); PolynomialFunction py = randomPolynomial(5, random); PolynomialFunction pz = randomPolynomial(5, random); PolynomialFunction pxDot = px.polynomialDerivative(); PolynomialFunction pyDot = py.polynomialDerivative(); PolynomialFunction pzDot = pz.polynomialDerivative(); PolynomialFunction pxDotDot = pxDot.polynomialDerivative(); PolynomialFunction pyDotDot = pyDot.polynomialDerivative(); PolynomialFunction pzDotDot = pzDot.polynomialDerivative(); List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>(); for (double dt : new double[] { 0.0, 0.5, 1.0 }) { Vector3D position = new Vector3D(px.value(dt), py.value(dt), pz.value(dt)); Vector3D velocity = new Vector3D(pxDot.value(dt), pyDot.value(dt), pzDot.value(dt)); sample.add(new TimeStampedPVCoordinates(t0.shiftedBy(dt), position, velocity, Vector3D.ZERO)); }//w ww . ja v a 2s .c o m for (double dt = 0; dt < 1.0; dt += 0.01) { TimeStampedPVCoordinates interpolated = TimeStampedPVCoordinates.interpolate(t0.shiftedBy(dt), CartesianDerivativesFilter.USE_PV, sample); Vector3D p = interpolated.getPosition(); Vector3D v = interpolated.getVelocity(); Vector3D a = interpolated.getAcceleration(); Assert.assertEquals(px.value(dt), p.getX(), 4.0e-16 * p.getNorm()); Assert.assertEquals(py.value(dt), p.getY(), 4.0e-16 * p.getNorm()); Assert.assertEquals(pz.value(dt), p.getZ(), 4.0e-16 * p.getNorm()); Assert.assertEquals(pxDot.value(dt), v.getX(), 9.0e-16 * v.getNorm()); Assert.assertEquals(pyDot.value(dt), v.getY(), 9.0e-16 * v.getNorm()); Assert.assertEquals(pzDot.value(dt), v.getZ(), 9.0e-16 * v.getNorm()); Assert.assertEquals(pxDotDot.value(dt), a.getX(), 1.0e-14 * a.getNorm()); Assert.assertEquals(pyDotDot.value(dt), a.getY(), 1.0e-14 * a.getNorm()); Assert.assertEquals(pzDotDot.value(dt), a.getZ(), 1.0e-14 * a.getNorm()); } } }
From source file:org.orekit.utils.TimeStampedPVCoordinatesTest.java
@Test public void testInterpolatePolynomialPositionOnly() { Random random = new Random(0x88740a12e4299003l); AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH; for (int i = 0; i < 20; ++i) { PolynomialFunction px = randomPolynomial(5, random); PolynomialFunction py = randomPolynomial(5, random); PolynomialFunction pz = randomPolynomial(5, random); PolynomialFunction pxDot = px.polynomialDerivative(); PolynomialFunction pyDot = py.polynomialDerivative(); PolynomialFunction pzDot = pz.polynomialDerivative(); PolynomialFunction pxDotDot = pxDot.polynomialDerivative(); PolynomialFunction pyDotDot = pyDot.polynomialDerivative(); PolynomialFunction pzDotDot = pzDot.polynomialDerivative(); List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>(); for (double dt : new double[] { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }) { Vector3D position = new Vector3D(px.value(dt), py.value(dt), pz.value(dt)); sample.add(new TimeStampedPVCoordinates(t0.shiftedBy(dt), position, Vector3D.ZERO, Vector3D.ZERO)); }// w ww. ja va2 s . c om for (double dt = 0; dt < 1.0; dt += 0.01) { TimeStampedPVCoordinates interpolated = TimeStampedPVCoordinates.interpolate(t0.shiftedBy(dt), CartesianDerivativesFilter.USE_P, sample); Vector3D p = interpolated.getPosition(); Vector3D v = interpolated.getVelocity(); Vector3D a = interpolated.getAcceleration(); Assert.assertEquals(px.value(dt), p.getX(), 5.0e-16 * p.getNorm()); Assert.assertEquals(py.value(dt), p.getY(), 5.0e-16 * p.getNorm()); Assert.assertEquals(pz.value(dt), p.getZ(), 5.0e-16 * p.getNorm()); Assert.assertEquals(pxDot.value(dt), v.getX(), 7.0e-15 * v.getNorm()); Assert.assertEquals(pyDot.value(dt), v.getY(), 7.0e-15 * v.getNorm()); Assert.assertEquals(pzDot.value(dt), v.getZ(), 7.0e-15 * v.getNorm()); Assert.assertEquals(pxDotDot.value(dt), a.getX(), 2.0e-13 * a.getNorm()); Assert.assertEquals(pyDotDot.value(dt), a.getY(), 2.0e-13 * a.getNorm()); Assert.assertEquals(pzDotDot.value(dt), a.getZ(), 2.0e-13 * a.getNorm()); } } }
From source file:org.orekit.utils.TimeStampedPVCoordinatesTest.java
@Test public void testInterpolateNonPolynomial() { AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH; List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>(); for (double dt : new double[] { 0.0, 0.5, 1.0 }) { Vector3D position = new Vector3D(FastMath.cos(dt), FastMath.sin(dt), 0.0); Vector3D velocity = new Vector3D(-FastMath.sin(dt), FastMath.cos(dt), 0.0); Vector3D acceleration = new Vector3D(-FastMath.cos(dt), -FastMath.sin(dt), 0.0); sample.add(new TimeStampedPVCoordinates(t0.shiftedBy(dt), position, velocity, acceleration)); }/* ww w . java 2s .c om*/ for (double dt = 0; dt < 1.0; dt += 0.01) { TimeStampedPVCoordinates interpolated = TimeStampedPVCoordinates.interpolate(t0.shiftedBy(dt), CartesianDerivativesFilter.USE_PVA, sample); Vector3D p = interpolated.getPosition(); Vector3D v = interpolated.getVelocity(); Vector3D a = interpolated.getAcceleration(); Assert.assertEquals(FastMath.cos(dt), p.getX(), 3.0e-10 * p.getNorm()); Assert.assertEquals(FastMath.sin(dt), p.getY(), 3.0e-10 * p.getNorm()); Assert.assertEquals(0, p.getZ(), 3.0e-10 * p.getNorm()); Assert.assertEquals(-FastMath.sin(dt), v.getX(), 3.0e-9 * v.getNorm()); Assert.assertEquals(FastMath.cos(dt), v.getY(), 3.0e-9 * v.getNorm()); Assert.assertEquals(0, v.getZ(), 3.0e-9 * v.getNorm()); Assert.assertEquals(-FastMath.cos(dt), a.getX(), 4.0e-8 * a.getNorm()); Assert.assertEquals(-FastMath.sin(dt), a.getY(), 4.0e-8 * a.getNorm()); Assert.assertEquals(0, a.getZ(), 4.0e-8 * a.getNorm()); } }
From source file:org.rhwlab.dispim.nucleus.NamedNucleusFile.java
License:asdf
static public RealMatrix rotationMatrix(Vector3D A, Vector3D B) { Vector3D a = A.normalize();// w ww . j av a 2 s . co m Vector3D b = B.normalize(); Vector3D v = a.crossProduct(b); double s = v.getNormSq(); double c = a.dotProduct(b); RealMatrix vx = MatrixUtils.createRealMatrix(3, 3); vx.setEntry(1, 0, v.getZ()); vx.setEntry(0, 1, -v.getZ()); vx.setEntry(2, 0, -v.getY()); vx.setEntry(0, 2, v.getY()); vx.setEntry(2, 1, v.getX()); vx.setEntry(1, 2, -v.getX()); RealMatrix vx2 = vx.multiply(vx); RealMatrix scaled = vx2.scalarMultiply((1.0 - c) / s); RealMatrix ident = MatrixUtils.createRealIdentityMatrix(3); RealMatrix sum = vx.add(scaled); RealMatrix ret = ident.add(sum); return ret; }
From source file:org.surmon.pattern.visualization.math.GLSphericalCoordinates.java
public GLSphericalCoordinates(Vector3D v) { super(new Vector3D(v.getZ(), v.getX(), v.getY())); }
From source file:org.surmon.pattern.visualization.math.GLSphericalCoordinates.java
@Override public Vector3D getCartesian() { Vector3D v = super.getCartesian(); return new Vector3D(v.getY(), v.getZ(), v.getX()); }
From source file:org.surmon.pattern.visualization.math.GLSphericalCoordinates.java
public Vec3 getCartesianGLM() { Vector3D v = super.getCartesian(); return new Vec3((float) v.getY(), (float) v.getZ(), (float) v.getX()); }
From source file:sceneGraph.Rot.java
public DVector applyTo(DVector v) { Vector3D result = new Vector3D((double) v.x, (double) v.y, (double) v.z); result = rotation.applyTo(result);/* w ww.j a v a 2 s.c om*/ return new DVector((double) result.getX(), (double) result.getY(), (double) result.getZ()); }