use of org.orekit.attitudes.Attitude in project Orekit by CS-SI.
the class AbstractParametricAcceleration method acceleration.
/**
* {@inheritDoc}
*/
@Override
public Vector3D acceleration(final SpacecraftState state, final double[] parameters) throws OrekitException {
final Vector3D inertialDirection;
if (isInertial) {
// the acceleration direction is already defined in the inertial frame
inertialDirection = direction;
} else {
final Attitude attitude;
if (attitudeOverride == null) {
// the acceleration direction is defined in spacecraft frame as set by the propagator
attitude = state.getAttitude();
} else {
// the acceleration direction is defined in a dedicated frame
attitude = attitudeOverride.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
}
inertialDirection = attitude.getRotation().applyInverseTo(direction);
}
return new Vector3D(signedAmplitude(state, parameters), inertialDirection);
}
use of org.orekit.attitudes.Attitude in project Orekit by CS-SI.
the class SpacecraftState method interpolate.
/**
* {@inheritDoc}
* <p>
* The additional states that are interpolated are the ones already present
* in the instance. The sample instances must therefore have at least the same
* additional states has the instance. They may have more additional states,
* but the extra ones will be ignored.
* </p>
* <p>
* As this implementation of interpolation is polynomial, it should be used only
* with small samples (about 10-20 points) in order to avoid <a
* href="http://en.wikipedia.org/wiki/Runge%27s_phenomenon">Runge's phenomenon</a>
* and numerical problems (including NaN appearing).
* </p>
*/
public SpacecraftState interpolate(final AbsoluteDate date, final Stream<SpacecraftState> sample) throws OrekitException {
// prepare interpolators
final List<Orbit> orbits = new ArrayList<>();
final List<Attitude> attitudes = new ArrayList<>();
final HermiteInterpolator massInterpolator = new HermiteInterpolator();
final Map<String, HermiteInterpolator> additionalInterpolators = new HashMap<String, HermiteInterpolator>(additional.size());
for (final String name : additional.keySet()) {
additionalInterpolators.put(name, new HermiteInterpolator());
}
// extract sample data
try {
sample.forEach(state -> {
try {
final double deltaT = state.getDate().durationFrom(date);
orbits.add(state.getOrbit());
attitudes.add(state.getAttitude());
massInterpolator.addSamplePoint(deltaT, new double[] { state.getMass() });
for (final Map.Entry<String, HermiteInterpolator> entry : additionalInterpolators.entrySet()) {
entry.getValue().addSamplePoint(deltaT, state.getAdditionalState(entry.getKey()));
}
} catch (OrekitException oe) {
throw new OrekitExceptionWrapper(oe);
}
});
} catch (OrekitExceptionWrapper oew) {
throw oew.getException();
}
// perform interpolations
final Orbit interpolatedOrbit = orbit.interpolate(date, orbits);
final Attitude interpolatedAttitude = attitude.interpolate(date, attitudes);
final double interpolatedMass = massInterpolator.value(0)[0];
final Map<String, double[]> interpolatedAdditional;
if (additional.isEmpty()) {
interpolatedAdditional = null;
} else {
interpolatedAdditional = new HashMap<String, double[]>(additional.size());
for (final Map.Entry<String, HermiteInterpolator> entry : additionalInterpolators.entrySet()) {
interpolatedAdditional.put(entry.getKey(), entry.getValue().value(0));
}
}
// create the complete interpolated state
return new SpacecraftState(interpolatedOrbit, interpolatedAttitude, interpolatedMass, interpolatedAdditional);
}
use of org.orekit.attitudes.Attitude in project Orekit by CS-SI.
the class SpacecraftStateTest method testDateConsistencyClose.
/**
* Check orbit and attitude dates can be off by a few ulps. I see this when using
* FixedRate attitude provider.
*/
@Test
public void testDateConsistencyClose() throws OrekitException {
// setup
Orbit orbit10Shifts = orbit;
for (int i = 0; i < 10; i++) {
orbit10Shifts = orbit10Shifts.shiftedBy(0.1);
}
final Orbit orbit1Shift = orbit.shiftedBy(1);
Attitude shiftedAttitude = attitudeLaw.getAttitude(orbit1Shift, orbit1Shift.getDate(), orbit.getFrame());
// verify dates are very close, but not equal
Assert.assertNotEquals(shiftedAttitude.getDate(), orbit10Shifts.getDate());
Assert.assertEquals(shiftedAttitude.getDate().durationFrom(orbit10Shifts.getDate()), 0, Precision.EPSILON);
// action + verify no exception is thrown
new SpacecraftState(orbit10Shifts, shiftedAttitude);
}
use of org.orekit.attitudes.Attitude in project Orekit by CS-SI.
the class FieldKeplerianPropagatorTest method doTestWrappedAttitudeException.
private <T extends RealFieldElement<T>> void doTestWrappedAttitudeException(Field<T> field) throws OrekitException {
T zero = field.getZero();
final FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(7.8e6), zero.add(0.032), zero.add(0.4), zero.add(0.1), zero.add(0.2), zero.add(0.3), PositionAngle.TRUE, FramesFactory.getEME2000(), new FieldAbsoluteDate<>(field), 3.986004415e14);
FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit, new AttitudeProvider() {
private static final long serialVersionUID = 1L;
public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
}
public <Q extends RealFieldElement<Q>> FieldAttitude<Q> getAttitude(FieldPVCoordinatesProvider<Q> pvProv, FieldAbsoluteDate<Q> date, Frame frame) throws OrekitException {
throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
}
});
propagator.propagate(orbit.getDate().shiftedBy(10.09));
}
use of org.orekit.attitudes.Attitude in project Orekit by CS-SI.
the class ConstantThrustManeuver method acceleration.
/**
* {@inheritDoc}
*/
@Override
public Vector3D acceleration(final SpacecraftState state, final double[] parameters) throws OrekitException {
if (firing) {
final double thrust = parameters[0];
final Attitude attitude = attitudeOverride == null ? state.getAttitude() : attitudeOverride.getAttitude(state.getOrbit(), state.getDate(), state.getFrame());
return new Vector3D(thrust / state.getMass(), attitude.getRotation().applyInverseTo(direction));
} else {
return Vector3D.ZERO;
}
}
Aggregations