use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class TopocentricFrameTest method testDoppler.
@Test
public void testDoppler() throws OrekitException {
// Surface point at latitude 45, longitude 5
final GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(45.), FastMath.toRadians(5.), 0.);
final TopocentricFrame topoFrame = new TopocentricFrame(earthSpheric, point, "lon 5 lat 45");
// Point at 30 deg longitude
// ***************************
final CircularOrbit orbit = new CircularOrbit(7178000.0, 0.5e-8, -0.5e-8, FastMath.toRadians(50.), FastMath.toRadians(120.), FastMath.toRadians(90.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
// Transform satellite position to position/velocity parameters in body frame
final Transform eme2000ToItrf = FramesFactory.getEME2000().getTransformTo(earthSpheric.getBodyFrame(), date);
final PVCoordinates pvSatItrf = eme2000ToItrf.transformPVCoordinates(orbit.getPVCoordinates());
// Compute range rate directly
// ********************************************
final double dop = topoFrame.getRangeRate(pvSatItrf, earthSpheric.getBodyFrame(), date);
// Compare to finite difference computation (2 points)
// *****************************************************
final double dt = 0.1;
KeplerianPropagator extrapolator = new KeplerianPropagator(orbit);
// Extrapolate satellite position a short while after reference date
AbsoluteDate dateP = date.shiftedBy(dt);
Transform j2000ToItrfP = FramesFactory.getEME2000().getTransformTo(earthSpheric.getBodyFrame(), dateP);
SpacecraftState orbitP = extrapolator.propagate(dateP);
Vector3D satPointGeoP = j2000ToItrfP.transformPVCoordinates(orbitP.getPVCoordinates()).getPosition();
// Retropolate satellite position a short while before reference date
AbsoluteDate dateM = date.shiftedBy(-dt);
Transform j2000ToItrfM = FramesFactory.getEME2000().getTransformTo(earthSpheric.getBodyFrame(), dateM);
SpacecraftState orbitM = extrapolator.propagate(dateM);
Vector3D satPointGeoM = j2000ToItrfM.transformPVCoordinates(orbitM.getPVCoordinates()).getPosition();
// Compute ranges at both instants
double rangeP = topoFrame.getRange(satPointGeoP, earthSpheric.getBodyFrame(), dateP);
double rangeM = topoFrame.getRange(satPointGeoM, earthSpheric.getBodyFrame(), dateM);
final double dopRef2 = (rangeP - rangeM) / (2. * dt);
Assert.assertEquals(dopRef2, dop, 1.e-3);
}
use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class TransformTest method testJacobianPVA.
@Test
public void testJacobianPVA() {
// base directions for finite differences
PVCoordinates[] directions = new PVCoordinates[] { new PVCoordinates(Vector3D.PLUS_I, Vector3D.ZERO, Vector3D.ZERO), new PVCoordinates(Vector3D.PLUS_J, Vector3D.ZERO, Vector3D.ZERO), new PVCoordinates(Vector3D.PLUS_K, Vector3D.ZERO, Vector3D.ZERO), new PVCoordinates(Vector3D.ZERO, Vector3D.PLUS_I, Vector3D.ZERO), new PVCoordinates(Vector3D.ZERO, Vector3D.PLUS_J, Vector3D.ZERO), new PVCoordinates(Vector3D.ZERO, Vector3D.PLUS_K, Vector3D.ZERO), new PVCoordinates(Vector3D.ZERO, Vector3D.ZERO, Vector3D.PLUS_I), new PVCoordinates(Vector3D.ZERO, Vector3D.ZERO, Vector3D.PLUS_J), new PVCoordinates(Vector3D.ZERO, Vector3D.ZERO, Vector3D.PLUS_K) };
double h = 0.01;
RandomGenerator random = new Well19937a(0xd223e88b6232198fl);
for (int i = 0; i < 20; ++i) {
// generate a random transform
Transform combined = randomTransform(random);
// compute Jacobian
double[][] jacobian = new double[9][9];
for (int l = 0; l < jacobian.length; ++l) {
for (int c = 0; c < jacobian[l].length; ++c) {
jacobian[l][c] = l + 0.1 * c;
}
}
combined.getJacobian(CartesianDerivativesFilter.USE_PVA, jacobian);
for (int j = 0; j < 100; ++j) {
PVCoordinates pv0 = new PVCoordinates(randomVector(1e3, random), randomVector(1.0, random), randomVector(1.0e-3, random));
double epsilonP = 2.0e-12 * pv0.getPosition().getNorm();
double epsilonV = 6.0e-11 * pv0.getVelocity().getNorm();
double epsilonA = 2.0e-9 * pv0.getAcceleration().getNorm();
for (int c = 0; c < directions.length; ++c) {
// eight points finite differences estimation of a Jacobian column
PVCoordinates pvm4h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, -4 * h, directions[c]));
PVCoordinates pvm3h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, -3 * h, directions[c]));
PVCoordinates pvm2h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, -2 * h, directions[c]));
PVCoordinates pvm1h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, -1 * h, directions[c]));
PVCoordinates pvp1h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, +1 * h, directions[c]));
PVCoordinates pvp2h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, +2 * h, directions[c]));
PVCoordinates pvp3h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, +3 * h, directions[c]));
PVCoordinates pvp4h = combined.transformPVCoordinates(new PVCoordinates(1.0, pv0, +4 * h, directions[c]));
PVCoordinates d4 = new PVCoordinates(pvm4h, pvp4h);
PVCoordinates d3 = new PVCoordinates(pvm3h, pvp3h);
PVCoordinates d2 = new PVCoordinates(pvm2h, pvp2h);
PVCoordinates d1 = new PVCoordinates(pvm1h, pvp1h);
double d = 1.0 / (840 * h);
PVCoordinates estimatedColumn = new PVCoordinates(-3 * d, d4, 32 * d, d3, -168 * d, d2, 672 * d, d1);
// check analytical Jacobian against finite difference reference
Assert.assertEquals(estimatedColumn.getPosition().getX(), jacobian[0][c], epsilonP);
Assert.assertEquals(estimatedColumn.getPosition().getY(), jacobian[1][c], epsilonP);
Assert.assertEquals(estimatedColumn.getPosition().getZ(), jacobian[2][c], epsilonP);
Assert.assertEquals(estimatedColumn.getVelocity().getX(), jacobian[3][c], epsilonV);
Assert.assertEquals(estimatedColumn.getVelocity().getY(), jacobian[4][c], epsilonV);
Assert.assertEquals(estimatedColumn.getVelocity().getZ(), jacobian[5][c], epsilonV);
Assert.assertEquals(estimatedColumn.getAcceleration().getX(), jacobian[6][c], epsilonA);
Assert.assertEquals(estimatedColumn.getAcceleration().getY(), jacobian[7][c], epsilonA);
Assert.assertEquals(estimatedColumn.getAcceleration().getZ(), jacobian[8][c], epsilonA);
}
}
}
}
use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class TransformTest method testAcceleration.
@Test
public void testAcceleration() {
PVCoordinates initPV = new PVCoordinates(new Vector3D(9, 8, 7), new Vector3D(6, 5, 4), new Vector3D(3, 2, 1));
for (double dt = 0; dt < 1; dt += 0.01) {
PVCoordinates basePV = initPV.shiftedBy(dt);
PVCoordinates transformedPV = evolvingTransform(AbsoluteDate.J2000_EPOCH, dt).transformPVCoordinates(basePV);
// rebuild transformed acceleration, relying only on transformed position and velocity
List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>();
double h = 1.0e-2;
for (int i = -3; i < 4; ++i) {
Transform t = evolvingTransform(AbsoluteDate.J2000_EPOCH, dt + i * h);
PVCoordinates pv = t.transformPVCoordinates(initPV.shiftedBy(dt + i * h));
sample.add(new TimeStampedPVCoordinates(t.getDate(), pv.getPosition(), pv.getVelocity(), Vector3D.ZERO));
}
PVCoordinates rebuiltPV = TimeStampedPVCoordinates.interpolate(AbsoluteDate.J2000_EPOCH.shiftedBy(dt), CartesianDerivativesFilter.USE_PV, sample);
checkVector(rebuiltPV.getPosition(), transformedPV.getPosition(), 4.0e-16);
checkVector(rebuiltPV.getVelocity(), transformedPV.getVelocity(), 2.0e-16);
checkVector(rebuiltPV.getAcceleration(), transformedPV.getAcceleration(), 9.0e-11);
}
}
use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class TransformTest method testRoughTransPV.
@Test
public void testRoughTransPV() {
PVCoordinates pointP1 = new PVCoordinates(Vector3D.PLUS_I, Vector3D.PLUS_I, Vector3D.PLUS_I);
// translation transform test
PVCoordinates pointP2 = new PVCoordinates(new Vector3D(0, 0, 0), new Vector3D(0, 0, 0));
Transform R1toR2 = new Transform(AbsoluteDate.J2000_EPOCH, Vector3D.MINUS_I, Vector3D.MINUS_I, Vector3D.MINUS_I);
PVCoordinates result1 = R1toR2.transformPVCoordinates(pointP1);
checkVector(pointP2.getPosition(), result1.getPosition(), 1.0e-15);
checkVector(pointP2.getVelocity(), result1.getVelocity(), 1.0e-15);
checkVector(pointP2.getAcceleration(), result1.getAcceleration(), 1.0e-15);
// test inverse translation
Transform R2toR1 = R1toR2.getInverse();
PVCoordinates invResult1 = R2toR1.transformPVCoordinates(pointP2);
checkVector(pointP1.getPosition(), invResult1.getPosition(), 1.0e-15);
checkVector(pointP1.getVelocity(), invResult1.getVelocity(), 1.0e-15);
checkVector(pointP1.getAcceleration(), invResult1.getAcceleration(), 1.0e-15);
// rotation transform test
PVCoordinates pointP3 = new PVCoordinates(Vector3D.PLUS_J, new Vector3D(-2, 1, 0), new Vector3D(-4, -3, -1));
Rotation R = new Rotation(Vector3D.PLUS_K, FastMath.PI / 2, RotationConvention.VECTOR_OPERATOR);
Transform R1toR3 = new Transform(AbsoluteDate.J2000_EPOCH, R, new Vector3D(0, 0, -2), new Vector3D(1, 0, 0));
PVCoordinates result2 = R1toR3.transformPVCoordinates(pointP1);
checkVector(pointP3.getPosition(), result2.getPosition(), 1.0e-15);
checkVector(pointP3.getVelocity(), result2.getVelocity(), 1.0e-15);
checkVector(pointP3.getAcceleration(), result2.getAcceleration(), 1.0e-15);
// test inverse rotation
Transform R3toR1 = R1toR3.getInverse();
PVCoordinates invResult2 = R3toR1.transformPVCoordinates(pointP3);
checkVector(pointP1.getPosition(), invResult2.getPosition(), 1.0e-15);
checkVector(pointP1.getVelocity(), invResult2.getVelocity(), 1.0e-15);
checkVector(pointP1.getAcceleration(), invResult2.getAcceleration(), 1.0e-15);
// combine 2 velocity transform
Transform R1toR4 = new Transform(AbsoluteDate.J2000_EPOCH, new Vector3D(-2, 0, 0), new Vector3D(-2, 0, 0), new Vector3D(-2, 0, 0));
PVCoordinates pointP4 = new PVCoordinates(new Vector3D(-1, 0, 0), new Vector3D(-1, 0, 0), new Vector3D(-1, 0, 0));
Transform R2toR4 = new Transform(AbsoluteDate.J2000_EPOCH, R2toR1, R1toR4);
PVCoordinates compResult = R2toR4.transformPVCoordinates(pointP2);
checkVector(pointP4.getPosition(), compResult.getPosition(), 1.0e-15);
checkVector(pointP4.getVelocity(), compResult.getVelocity(), 1.0e-15);
checkVector(pointP4.getAcceleration(), compResult.getAcceleration(), 1.0e-15);
// combine 2 rotation tranform
PVCoordinates pointP5 = new PVCoordinates(new Vector3D(-1, 0, 0), new Vector3D(-1, 0, 3), new Vector3D(8, 0, 6));
Rotation R2 = new Rotation(new Vector3D(0, 0, 1), FastMath.PI, RotationConvention.VECTOR_OPERATOR);
Transform R1toR5 = new Transform(AbsoluteDate.J2000_EPOCH, R2, new Vector3D(0, -3, 0));
Transform R3toR5 = new Transform(AbsoluteDate.J2000_EPOCH, R3toR1, R1toR5);
PVCoordinates combResult = R3toR5.transformPVCoordinates(pointP3);
checkVector(pointP5.getPosition(), combResult.getPosition(), 1.0e-15);
checkVector(pointP5.getVelocity(), combResult.getVelocity(), 1.0e-15);
checkVector(pointP5.getAcceleration(), combResult.getAcceleration(), 1.0e-15);
// combine translation and rotation
Transform R2toR3 = new Transform(AbsoluteDate.J2000_EPOCH, R2toR1, R1toR3);
PVCoordinates result = R2toR3.transformPVCoordinates(pointP2);
checkVector(pointP3.getPosition(), result.getPosition(), 1.0e-15);
checkVector(pointP3.getVelocity(), result.getVelocity(), 1.0e-15);
checkVector(pointP3.getAcceleration(), result.getAcceleration(), 1.0e-15);
Transform R3toR2 = new Transform(AbsoluteDate.J2000_EPOCH, R3toR1, R1toR2);
result = R3toR2.transformPVCoordinates(pointP3);
checkVector(pointP2.getPosition(), result.getPosition(), 1.0e-15);
checkVector(pointP2.getVelocity(), result.getVelocity(), 1.0e-15);
checkVector(pointP2.getAcceleration(), result.getAcceleration(), 1.0e-15);
Transform newR1toR5 = new Transform(AbsoluteDate.J2000_EPOCH, R1toR2, R2toR3);
newR1toR5 = new Transform(AbsoluteDate.J2000_EPOCH, newR1toR5, R3toR5);
result = newR1toR5.transformPVCoordinates(pointP1);
checkVector(pointP5.getPosition(), result.getPosition(), 1.0e-15);
checkVector(pointP5.getVelocity(), result.getVelocity(), 1.0e-15);
checkVector(pointP5.getAcceleration(), result.getAcceleration(), 1.0e-15);
// more tests
newR1toR5 = new Transform(AbsoluteDate.J2000_EPOCH, R1toR2, R2toR3);
Transform R3toR4 = new Transform(AbsoluteDate.J2000_EPOCH, R3toR1, R1toR4);
newR1toR5 = new Transform(AbsoluteDate.J2000_EPOCH, newR1toR5, R3toR4);
Transform R4toR5 = new Transform(AbsoluteDate.J2000_EPOCH, R1toR4.getInverse(), R1toR5);
newR1toR5 = new Transform(AbsoluteDate.J2000_EPOCH, newR1toR5, R4toR5);
result = newR1toR5.transformPVCoordinates(pointP1);
checkVector(pointP5.getPosition(), result.getPosition(), 1.0e-15);
checkVector(pointP5.getVelocity(), result.getVelocity(), 1.0e-15);
checkVector(pointP5.getAcceleration(), result.getAcceleration(), 1.0e-15);
}
use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class TransformTest method testTransPV.
@Test
public void testTransPV() {
RandomGenerator rnd = new Well19937a(0x73d5554d99427af0l);
for (int i = 0; i < 10; ++i) {
// random position, velocity and acceleration
Vector3D pos = randomVector(1.0e3, rnd);
Vector3D vel = randomVector(1.0, rnd);
Vector3D acc = randomVector(1.0e-3, rnd);
PVCoordinates pvOne = new PVCoordinates(pos, vel, acc);
// random transform
Vector3D transPos = randomVector(1.0e3, rnd);
Vector3D transVel = randomVector(1.0, rnd);
Vector3D transAcc = randomVector(1.0e-3, rnd);
Transform tr = new Transform(AbsoluteDate.J2000_EPOCH, transPos, transVel, transAcc);
double dt = 1;
// we should obtain
Vector3D good = tr.transformPosition(pos.add(new Vector3D(dt, vel))).add(new Vector3D(dt, transVel));
// we have
PVCoordinates pvTwo = tr.transformPVCoordinates(pvOne);
Vector3D result = pvTwo.getPosition().add(new Vector3D(dt, pvTwo.getVelocity()));
checkVector(good, result, 1.0e-15);
FieldPVCoordinates<Decimal64> fieldPVOne = new FieldPVCoordinates<Decimal64>(new FieldVector3D<Decimal64>(Decimal64Field.getInstance(), pvOne.getPosition()), new FieldVector3D<Decimal64>(Decimal64Field.getInstance(), pvOne.getVelocity()), new FieldVector3D<Decimal64>(Decimal64Field.getInstance(), pvOne.getAcceleration()));
FieldPVCoordinates<Decimal64> fieldPVTwo = tr.transformPVCoordinates(fieldPVOne);
FieldVector3D<Decimal64> fieldResult = fieldPVTwo.getPosition().add(new FieldVector3D<Decimal64>(dt, fieldPVTwo.getVelocity()));
checkVector(good, fieldResult.toVector3D(), 1.0e-15);
TimeStampedFieldPVCoordinates<Decimal64> fieldTPVOne = new TimeStampedFieldPVCoordinates<Decimal64>(tr.getDate(), new FieldVector3D<Decimal64>(Decimal64Field.getInstance(), pvOne.getPosition()), new FieldVector3D<Decimal64>(Decimal64Field.getInstance(), pvOne.getVelocity()), new FieldVector3D<Decimal64>(Decimal64Field.getInstance(), pvOne.getAcceleration()));
TimeStampedFieldPVCoordinates<Decimal64> fieldTPVTwo = tr.transformPVCoordinates(fieldTPVOne);
FieldVector3D<Decimal64> fieldTResult = fieldTPVTwo.getPosition().add(new FieldVector3D<Decimal64>(dt, fieldTPVTwo.getVelocity()));
checkVector(good, fieldTResult.toVector3D(), 1.0e-15);
// test inverse
Vector3D resultvel = tr.getInverse().transformPVCoordinates(pvTwo).getVelocity();
checkVector(resultvel, vel, 1.0e-15);
}
}
Aggregations