use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class PartialDerivativesTest method testJacobianIssue18.
@Test
public void testJacobianIssue18() throws OrekitException {
// Body mu
final double mu = 3.9860047e14;
final double isp = 318;
final double mass = 2500;
final double a = 24396159;
final double e = 0.72831215;
final double i = FastMath.toRadians(7);
final double omega = FastMath.toRadians(180);
final double OMEGA = FastMath.toRadians(261);
final double lv = 0;
final double duration = 3653.99;
final double f = 420;
final double delta = FastMath.toRadians(-7.4978);
final double alpha = FastMath.toRadians(351);
final AttitudeProvider law = new InertialProvider(new Rotation(new Vector3D(alpha, delta), Vector3D.PLUS_I));
final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01), new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC());
final Orbit orbit = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu);
final SpacecraftState initialState = new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);
final AbsoluteDate fireDate = new AbsoluteDate(new DateComponents(2004, 01, 02), new TimeComponents(04, 15, 34.080), TimeScalesFactory.getUTC());
final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(fireDate, duration, f, isp, Vector3D.PLUS_I);
double[] absTolerance = { 0.001, 1.0e-9, 1.0e-9, 1.0e-6, 1.0e-6, 1.0e-6, 0.001 };
double[] relTolerance = { 1.0e-7, 1.0e-4, 1.0e-4, 1.0e-7, 1.0e-7, 1.0e-7, 1.0e-7 };
AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 1000, absTolerance, relTolerance);
integrator.setInitialStepSize(60);
final NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.setAttitudeProvider(law);
propagator.addForceModel(maneuver);
maneuver.getParameterDriver("thrust").setSelected(true);
propagator.setOrbitType(OrbitType.CARTESIAN);
PartialDerivativesEquations PDE = new PartialDerivativesEquations("derivatives", propagator);
Assert.assertEquals(1, PDE.getSelectedParameters().getNbParams());
propagator.setInitialState(PDE.setInitialJacobians(initialState));
final AbsoluteDate finalDate = fireDate.shiftedBy(3800);
final SpacecraftState finalorb = propagator.propagate(finalDate);
Assert.assertEquals(0, finalDate.durationFrom(finalorb.getDate()), 1.0e-11);
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class EstimatedEarthFrameProvider method getTransform.
/**
* {@inheritDoc}
*/
@Override
public Transform getTransform(final AbsoluteDate date) throws OrekitException {
// take parametric prime meridian shift into account
final double theta = linearModel(date, primeMeridianOffsetDriver, primeMeridianDriftDriver);
final double thetaDot = parametricModel(primeMeridianDriftDriver);
final Transform meridianShift = new Transform(date, new Rotation(Vector3D.PLUS_K, theta, RotationConvention.FRAME_TRANSFORM), new Vector3D(0, 0, thetaDot));
// take parametric pole shift into account
final double xpNeg = -linearModel(date, polarOffsetXDriver, polarDriftXDriver);
final double ypNeg = -linearModel(date, polarOffsetYDriver, polarDriftYDriver);
final double xpNegDot = -parametricModel(polarDriftXDriver);
final double ypNegDot = -parametricModel(polarDriftYDriver);
final Transform poleShift = new Transform(date, new Transform(date, new Rotation(Vector3D.PLUS_J, xpNeg, RotationConvention.FRAME_TRANSFORM), new Vector3D(0.0, xpNegDot, 0.0)), new Transform(date, new Rotation(Vector3D.PLUS_I, ypNeg, RotationConvention.FRAME_TRANSFORM), new Vector3D(ypNegDot, 0.0, 0.0)));
return new Transform(date, meridianShift, poleShift);
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class CartesianOrbit method shiftPVHyperbolic.
/**
* Compute shifted position and velocity in hyperbolic case.
* @param dt time shift
* @return shifted position and velocity
*/
private PVCoordinates shiftPVHyperbolic(final double dt) {
final PVCoordinates pv = getPVCoordinates();
final Vector3D pvP = pv.getPosition();
final Vector3D pvV = pv.getVelocity();
final Vector3D pvM = pv.getMomentum();
final double r2 = pvP.getNormSq();
final double r = FastMath.sqrt(r2);
final double rV2OnMu = r * pvV.getNormSq() / getMu();
final double a = getA();
final double muA = getMu() * a;
final double e = FastMath.sqrt(1 - Vector3D.dotProduct(pvM, pvM) / muA);
final double sqrt = FastMath.sqrt((e + 1) / (e - 1));
// compute mean anomaly
final double eSH = Vector3D.dotProduct(pvP, pvV) / FastMath.sqrt(-muA);
final double eCH = rV2OnMu - 1;
final double H0 = FastMath.log((eCH + eSH) / (eCH - eSH)) / 2;
final double M0 = e * FastMath.sinh(H0) - H0;
// find canonical 2D frame with p pointing to perigee
final double v0 = 2 * FastMath.atan(sqrt * FastMath.tanh(H0 / 2));
final Vector3D p = new Rotation(pvM, v0, RotationConvention.FRAME_TRANSFORM).applyTo(pvP).normalize();
final Vector3D q = Vector3D.crossProduct(pvM, p).normalize();
// compute shifted eccentric anomaly
final double M1 = M0 + getKeplerianMeanMotion() * dt;
final double H1 = meanToHyperbolicEccentric(M1, e);
// compute shifted in-plane Cartesian coordinates
final double cH = FastMath.cosh(H1);
final double sH = FastMath.sinh(H1);
final double sE2m1 = FastMath.sqrt((e - 1) * (e + 1));
// coordinates of position and velocity in the orbital plane
final double x = a * (cH - e);
final double y = -a * sE2m1 * sH;
final double factor = FastMath.sqrt(getMu() / -a) / (e * cH - 1);
final double xDot = -factor * sH;
final double yDot = factor * sE2m1 * cH;
final Vector3D shiftedP = new Vector3D(x, p, y, q);
final Vector3D shiftedV = new Vector3D(xDot, p, yDot, q);
if (hasNonKeplerianAcceleration) {
// extract non-Keplerian part of the initial acceleration
final Vector3D nonKeplerianAcceleration = new Vector3D(1, getPVCoordinates().getAcceleration(), getMu() / (r2 * r), pvP);
// add the quadratic motion due to the non-Keplerian acceleration to the Keplerian motion
final Vector3D fixedP = new Vector3D(1, shiftedP, 0.5 * dt * dt, nonKeplerianAcceleration);
final double fixedR2 = fixedP.getNormSq();
final double fixedR = FastMath.sqrt(fixedR2);
final Vector3D fixedV = new Vector3D(1, shiftedV, dt, nonKeplerianAcceleration);
final Vector3D fixedA = new Vector3D(-getMu() / (fixedR2 * fixedR), shiftedP, 1, nonKeplerianAcceleration);
return new PVCoordinates(fixedP, fixedV, fixedA);
} else {
// so the shifted orbit is not considered to have derivatives
return new PVCoordinates(shiftedP, shiftedV);
}
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class TargetPointingTest method testConstructors.
/**
* Test if both constructors are equivalent
*/
@Test
public void testConstructors() throws OrekitException {
// Satellite position
// ********************
CircularOrbit circ = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.), FastMath.toRadians(270.), FastMath.toRadians(5.300), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
// Attitude laws
// ***************
// Elliptic earth shape
OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, itrf);
// Target definition as a geodetic point AND as a position/velocity vector
GeodeticPoint geoTargetITRF = new GeodeticPoint(FastMath.toRadians(43.36), FastMath.toRadians(1.26), 600.);
Vector3D pTargetITRF = earthShape.transform(geoTargetITRF);
// Attitude law definition from geodetic point target
TargetPointing geoTargetAttitudeLaw = new TargetPointing(circ.getFrame(), geoTargetITRF, earthShape);
// Attitude law definition from position/velocity target
TargetPointing pvTargetAttitudeLaw = new TargetPointing(circ.getFrame(), itrf, pTargetITRF);
// Check that both attitude are the same
// Get satellite rotation for target pointing law
Rotation rotPv = pvTargetAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation();
// Get satellite rotation for nadir pointing law
Rotation rotGeo = geoTargetAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation();
// Rotations composition
Rotation rotCompo = rotGeo.composeInverse(rotPv, RotationConvention.VECTOR_OPERATOR);
double angle = rotCompo.getAngle();
Assert.assertEquals(angle, 0.0, Utils.epsilonAngle);
}
use of org.hipparchus.geometry.euclidean.threed.Rotation in project Orekit by CS-SI.
the class TargetPointingTest method testTargetInPointingDirection.
/**
* Test if defined target belongs to the direction pointed by the satellite
*/
@Test
public void testTargetInPointingDirection() throws OrekitException {
// Create computation date
AbsoluteDate date = new AbsoluteDate(new DateComponents(2008, 04, 07), TimeComponents.H00, TimeScalesFactory.getUTC());
// Reference frame = ITRF
Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
// Elliptic earth shape
OneAxisEllipsoid earthShape = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, itrf);
// Create target pointing attitude provider
GeodeticPoint geoTarget = new GeodeticPoint(FastMath.toRadians(43.36), FastMath.toRadians(1.26), 600.);
TargetPointing targetAttitudeLaw = new TargetPointing(FramesFactory.getEME2000(), geoTarget, earthShape);
// Satellite position
// ********************
// Create satellite position as circular parameters
CircularOrbit circ = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.), FastMath.toRadians(270.), FastMath.toRadians(5.300), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
// 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 = targetAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation();
// Transform Z axis from satellite frame to EME2000
Vector3D zSatEME2000 = rotSatEME2000.applyInverseTo(Vector3D.PLUS_K);
// Line containing satellite point and following pointing direction
Vector3D p = eme2000ToItrf.transformPosition(pvSatEME2000.getPosition());
Line pointingLine = new Line(p, p.add(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, eme2000ToItrf.transformVector(zSatEME2000)), 1.0e-10);
// Check that the line contains earth center
double distance = pointingLine.distance(earthShape.transform(geoTarget));
Assert.assertEquals(0, distance, 1.e-7);
}
Aggregations