use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class AltitudeDetector method g.
/**
* Compute the value of the switching function.
* This function measures the difference between the current altitude
* and the threshold altitude.
* @param s the current state information: date, kinematics, attitude
* @return value of the switching function
* @exception OrekitException if some specific error occurs
*/
public double g(final SpacecraftState s) throws OrekitException {
final Frame bodyFrame = bodyShape.getBodyFrame();
final PVCoordinates pvBody = s.getPVCoordinates(bodyFrame);
final GeodeticPoint point = bodyShape.transform(pvBody.getPosition(), bodyFrame, s.getDate());
return point.getAltitude() - altitude;
}
use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class CelestialBodyPointed method getAttitude.
/**
* {@inheritDoc}
*/
public Attitude getAttitude(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) throws OrekitException {
final PVCoordinates satPV = pvProv.getPVCoordinates(date, celestialFrame);
// compute celestial references at the specified date
final PVCoordinates bodyPV = pointedBody.getPVCoordinates(date, celestialFrame);
final PVCoordinates pointing = new PVCoordinates(satPV, bodyPV);
final Vector3D pointingP = pointing.getPosition();
final double r2 = Vector3D.dotProduct(pointingP, pointingP);
// evaluate instant rotation axis due to sat and body motion only (no phasing yet)
final Vector3D rotAxisCel = new Vector3D(1 / r2, Vector3D.crossProduct(pointingP, pointing.getVelocity()));
// fix instant rotation to take phasing constraint into account
// (adding a rotation around pointing axis ensuring the motion of the phasing axis
// is constrained in the pointing-phasing plane)
final Vector3D v1 = Vector3D.crossProduct(rotAxisCel, phasingCel);
final Vector3D v2 = Vector3D.crossProduct(pointingP, phasingCel);
final double compensation = -Vector3D.dotProduct(v1, v2) / v2.getNormSq();
final Vector3D phasedRotAxisCel = new Vector3D(1.0, rotAxisCel, compensation, pointingP);
// compute transform from celestial frame to satellite frame
final Rotation celToSatRotation = new Rotation(pointingP, phasingCel, pointingSat, phasingSat);
// build transform combining rotation and instant rotation axis
Transform transform = new Transform(date, celToSatRotation, celToSatRotation.applyTo(phasedRotAxisCel));
if (frame != celestialFrame) {
// prepend transform from specified frame to celestial frame
transform = new Transform(date, frame.getTransformTo(celestialFrame, date), transform);
}
// build the attitude
return new Attitude(date, frame, transform.getRotation(), transform.getRotationRate(), transform.getRotationAcceleration());
}
use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class LofOffset method getAttitude.
/**
* {@inheritDoc}
*/
public Attitude getAttitude(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) throws OrekitException {
// construction of the local orbital frame, using PV from inertial frame
final PVCoordinates pv = pvProv.getPVCoordinates(date, inertialFrame);
final Transform inertialToLof = type.transformFromInertial(date, pv);
// take into account the specified start frame (which may not be an inertial one)
final Transform frameToInertial = frame.getTransformTo(inertialFrame, date);
final Transform frameToLof = new Transform(date, frameToInertial, inertialToLof);
// compose with offset rotation
return new Attitude(date, frame, offset.compose(frameToLof.getRotation(), RotationConvention.VECTOR_OPERATOR), offset.applyTo(frameToLof.getRotationRate()), offset.applyTo(frameToLof.getRotationAcceleration()));
}
use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class TabulatedLofOffset method getAttitude.
/**
* {@inheritDoc}
*/
public Attitude getAttitude(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) throws OrekitException {
// get attitudes sample on which interpolation will be performed
final List<TimeStampedAngularCoordinates> sample = table.getNeighbors(date).collect(Collectors.toList());
// interpolate
final TimeStampedAngularCoordinates interpolated = TimeStampedAngularCoordinates.interpolate(date, filter, sample);
// construction of the local orbital frame, using PV from inertial frame
final PVCoordinates pv = pvProv.getPVCoordinates(date, inertialFrame);
final Transform inertialToLof = type.transformFromInertial(date, pv);
// take into account the specified start frame (which may not be an inertial one)
final Transform frameToInertial = frame.getTransformTo(inertialFrame, date);
final Transform frameToLof = new Transform(date, frameToInertial, inertialToLof);
// compose with interpolated rotation
return new Attitude(date, frame, interpolated.addOffset(frameToLof.getAngular()));
}
use of org.orekit.utils.PVCoordinates in project Orekit by CS-SI.
the class RelativityTest method testSmallEffectOnOrbit.
/**
* check against example in Tapley, Schutz, and Born, p 65-66. They predict a
* progression of perigee of 11 arcsec/year. To get the same results we must set the
* propagation tolerances to 1e-5.
*
* @throws OrekitException on error
*/
@Test
public void testSmallEffectOnOrbit() throws OrekitException {
// setup
final double gm = Constants.EIGEN5C_EARTH_MU;
Orbit orbit = new KeplerianOrbit(7500e3, 0.025, FastMath.toRadians(41.2), 0, 0, 0, PositionAngle.TRUE, frame, date, gm);
double[][] tol = NumericalPropagator.tolerances(0.00001, orbit, OrbitType.CARTESIAN);
AbstractIntegrator integrator = new DormandPrince853Integrator(1, 3600, tol[0], tol[1]);
NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.setOrbitType(OrbitType.CARTESIAN);
propagator.addForceModel(new Relativity(gm));
propagator.setInitialState(new SpacecraftState(orbit));
// action: propagate a period
AbsoluteDate end = orbit.getDate().shiftedBy(30 * Constants.JULIAN_DAY);
PVCoordinates actual = propagator.getPVCoordinates(end, frame);
// verify
KeplerianOrbit endOrbit = new KeplerianOrbit(actual, frame, end, gm);
KeplerianOrbit startOrbit = new KeplerianOrbit(orbit);
double dp = endOrbit.getPerigeeArgument() - startOrbit.getPerigeeArgument();
double dtYears = end.durationFrom(orbit.getDate()) / Constants.JULIAN_YEAR;
double dpDeg = FastMath.toDegrees(dp);
// change in argument of perigee in arcseconds per year
double arcsecPerYear = dpDeg * 3600 / dtYears;
Assert.assertEquals(11, arcsecPerYear, 0.5);
}
Aggregations