use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class AttitudeTest method testSpin.
@Test
public void testSpin() throws OrekitException {
double rate = 2 * FastMath.PI / (12 * 60);
Attitude attitude = new Attitude(AbsoluteDate.J2000_EPOCH, FramesFactory.getEME2000(), new Rotation(0.48, 0.64, 0.36, 0.48, false), new Vector3D(rate, Vector3D.PLUS_K), Vector3D.ZERO);
Assert.assertEquals(rate, attitude.getSpin().getNorm(), 1.0e-10);
double dt = 10.0;
Attitude shifted = attitude.shiftedBy(dt);
Assert.assertEquals(rate, shifted.getSpin().getNorm(), 1.0e-10);
Assert.assertEquals(rate * dt, Rotation.distance(attitude.getRotation(), shifted.getRotation()), 1.0e-10);
Vector3D shiftedX = shifted.getRotation().applyInverseTo(Vector3D.PLUS_I);
Vector3D shiftedY = shifted.getRotation().applyInverseTo(Vector3D.PLUS_J);
Vector3D shiftedZ = shifted.getRotation().applyInverseTo(Vector3D.PLUS_K);
Vector3D originalX = attitude.getRotation().applyInverseTo(Vector3D.PLUS_I);
Vector3D originalY = attitude.getRotation().applyInverseTo(Vector3D.PLUS_J);
Vector3D originalZ = attitude.getRotation().applyInverseTo(Vector3D.PLUS_K);
Assert.assertEquals(FastMath.cos(rate * dt), Vector3D.dotProduct(shiftedX, originalX), 1.0e-10);
Assert.assertEquals(FastMath.sin(rate * dt), Vector3D.dotProduct(shiftedX, originalY), 1.0e-10);
Assert.assertEquals(0.0, Vector3D.dotProduct(shiftedX, originalZ), 1.0e-10);
Assert.assertEquals(-FastMath.sin(rate * dt), Vector3D.dotProduct(shiftedY, originalX), 1.0e-10);
Assert.assertEquals(FastMath.cos(rate * dt), Vector3D.dotProduct(shiftedY, originalY), 1.0e-10);
Assert.assertEquals(0.0, Vector3D.dotProduct(shiftedY, originalZ), 1.0e-10);
Assert.assertEquals(0.0, Vector3D.dotProduct(shiftedZ, originalX), 1.0e-10);
Assert.assertEquals(0.0, Vector3D.dotProduct(shiftedZ, originalY), 1.0e-10);
Assert.assertEquals(1.0, Vector3D.dotProduct(shiftedZ, originalZ), 1.0e-10);
Vector3D forward = AngularCoordinates.estimateRate(attitude.getRotation(), shifted.getRotation(), dt);
Assert.assertEquals(0.0, forward.subtract(attitude.getSpin()).getNorm(), 1.0e-10);
Vector3D reversed = AngularCoordinates.estimateRate(shifted.getRotation(), attitude.getRotation(), dt);
Assert.assertEquals(0.0, reversed.add(attitude.getSpin()).getNorm(), 1.0e-10);
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class BodyCenterPointingTest method testBodyCenterInPointingDirection.
/**
* Test if body center belongs to the direction pointed by the satellite
*/
@Test
public void testBodyCenterInPointingDirection() throws OrekitException {
// Transform satellite position to position/velocity parameters in EME2000 frame
PVCoordinates pvSatEME2000 = circ.getPVCoordinates();
// Pointing direction
// ********************
// Get satellite attitude rotation, i.e rotation from EME2000 frame to satellite frame
Rotation rotSatEME2000 = earthCenterAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation();
// Transform Z axis from satellite frame to EME2000
Vector3D zSatEME2000 = rotSatEME2000.applyInverseTo(Vector3D.PLUS_K);
// Transform Z axis from EME2000 to ITRF2008
Vector3D zSatITRF2008C = eme2000ToItrf.transformVector(zSatEME2000);
// Transform satellite position/velocity from EME2000 to ITRF2008
PVCoordinates pvSatITRF2008C = eme2000ToItrf.transformPVCoordinates(pvSatEME2000);
// Line containing satellite point and following pointing direction
Line pointingLine = new Line(pvSatITRF2008C.getPosition(), pvSatITRF2008C.getPosition().add(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, zSatITRF2008C), 2.0e-8);
// Check that the line contains Earth center
Assert.assertTrue(pointingLine.contains(Vector3D.ZERO));
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class InertialAttitudeTest method testSpin.
@Test
public void testSpin() throws OrekitException {
AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 01, 01), new TimeComponents(3, 25, 45.6789), TimeScalesFactory.getUTC());
AttitudeProvider law = new InertialProvider(new Rotation(new Vector3D(-0.64, 0.6, 0.48), 0.2, RotationConvention.VECTOR_OPERATOR));
KeplerianOrbit orbit = new KeplerianOrbit(7178000.0, 1.e-4, FastMath.toRadians(50.), FastMath.toRadians(10.), FastMath.toRadians(20.), FastMath.toRadians(30.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, 3.986004415e14);
Propagator propagator = new KeplerianPropagator(orbit, law);
double h = 100.0;
SpacecraftState sMinus = propagator.propagate(date.shiftedBy(-h));
SpacecraftState s0 = propagator.propagate(date);
SpacecraftState sPlus = propagator.propagate(date.shiftedBy(h));
// check spin is consistent with attitude evolution
double errorAngleMinus = Rotation.distance(sMinus.shiftedBy(h).getAttitude().getRotation(), s0.getAttitude().getRotation());
double evolutionAngleMinus = Rotation.distance(sMinus.getAttitude().getRotation(), s0.getAttitude().getRotation());
Assert.assertEquals(0.0, errorAngleMinus, 1.0e-6 * evolutionAngleMinus);
double errorAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.shiftedBy(-h).getAttitude().getRotation());
double evolutionAnglePlus = Rotation.distance(s0.getAttitude().getRotation(), sPlus.getAttitude().getRotation());
Assert.assertEquals(0.0, errorAnglePlus, 1.0e-6 * evolutionAnglePlus);
// compute spin axis using finite differences
Rotation rMinus = sMinus.getAttitude().getRotation();
Rotation rPlus = sPlus.getAttitude().getRotation();
Rotation dr = rPlus.compose(rMinus.revert(), RotationConvention.VECTOR_OPERATOR);
Assert.assertEquals(0, dr.getAngle(), 1.0e-10);
Vector3D spin0 = s0.getAttitude().getSpin();
Assert.assertEquals(0, spin0.getNorm(), 1.0e-10);
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class InertialAttitudeTest method testCompensateMomentum.
@Test
public void testCompensateMomentum() throws OrekitException {
InertialProvider law = new InertialProvider(new Rotation(new Vector3D(-0.64, 0.6, 0.48), 0.2, RotationConvention.VECTOR_OPERATOR));
KeplerianPropagator propagator = new KeplerianPropagator(orbit0, law);
Attitude initial = propagator.propagate(t0).getAttitude();
for (double t = 0; t < 10000.0; t += 100) {
Attitude attitude = propagator.propagate(t0.shiftedBy(t)).getAttitude();
Rotation evolution = attitude.getRotation().compose(initial.getRotation().revert(), RotationConvention.VECTOR_OPERATOR);
Assert.assertEquals(0, evolution.getAngle(), 1.0e-10);
Assert.assertEquals(FramesFactory.getEME2000(), attitude.getReferenceFrame());
}
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class LofOffsetTest method testTarget.
/**
* Test is the target pointed is the one expected
*/
@Test
public void testTarget() throws OrekitException {
// Create target point and target pointing law towards that point
final GeodeticPoint targetDef = new GeodeticPoint(FastMath.toRadians(5.), FastMath.toRadians(-40.), 0.);
final TargetPointing targetLaw = new TargetPointing(orbit.getFrame(), targetDef, earthSpheric);
// Get roll, pitch, yaw angles corresponding to this pointing law
final LofOffset lofAlignedLaw = new LofOffset(orbit.getFrame(), LOFType.VVLH);
final Rotation lofAlignedRot = lofAlignedLaw.getAttitude(orbit, date, orbit.getFrame()).getRotation();
final Attitude targetAttitude = targetLaw.getAttitude(orbit, date, orbit.getFrame());
final Rotation rollPitchYaw = targetAttitude.getRotation().compose(lofAlignedRot.revert(), RotationConvention.VECTOR_OPERATOR).revert();
final double[] angles = rollPitchYaw.getAngles(RotationOrder.ZYX, RotationConvention.VECTOR_OPERATOR);
final double yaw = angles[0];
final double pitch = angles[1];
final double roll = angles[2];
// Create a lof offset law from those values
final LofOffset lofOffsetLaw = new LofOffset(orbit.getFrame(), LOFType.VVLH, RotationOrder.ZYX, yaw, pitch, roll);
final LofOffsetPointing lofOffsetPtLaw = new LofOffsetPointing(orbit.getFrame(), earthSpheric, lofOffsetLaw, Vector3D.PLUS_K);
// Check target pointed by this law : shall be the same as defined
final Vector3D pTargetRes = lofOffsetPtLaw.getTargetPV(orbit, date, earthSpheric.getBodyFrame()).getPosition();
final GeodeticPoint targetRes = earthSpheric.transform(pTargetRes, earthSpheric.getBodyFrame(), date);
Assert.assertEquals(targetDef.getLongitude(), targetRes.getLongitude(), Utils.epsilonAngle);
Assert.assertEquals(targetDef.getLongitude(), targetRes.getLongitude(), Utils.epsilonAngle);
}
Aggregations