public class WaypointPropagator extends CartesianOnePointPropagator
The following example shows how to use the WaypointPropagator
to move between waypoints at a constant velocity:
EarthCentralBody earth = CentralBodiesFacet.getFromContext().getEarth();
final double constantVelocity = 80.0;
JulianDate startDate = new JulianDate(new GregorianDate(2007, 12, 6, 12, 0, 0.0));
// Create the start point of our route with a particular date, location, and velocity.
Cartographic point1 = new Cartographic(Trig.degreesToRadians(-77.28), Trig.degreesToRadians(39.94), 3000.0);
Waypoint waypoint1 = new Waypoint(startDate, point1, constantVelocity, 0.0);
// Create the next two waypoints from a location, the same velocity, and the previous waypoint.
Cartographic point2 = new Cartographic(Trig.degreesToRadians(-79.59), Trig.degreesToRadians(38.81), 3000.0);
Waypoint waypoint2 = new Waypoint(waypoint1, earth.getShape(), point2, constantVelocity);
Cartographic point3 = new Cartographic(Trig.degreesToRadians(-81.44), Trig.degreesToRadians(39.69), 3000.0);
Waypoint waypoint3 = new Waypoint(waypoint2, earth.getShape(), point3, constantVelocity);
// Construct the waypoint propagator with all of the waypoints
ArrayList<Waypoint> waypoints = new ArrayList<>();
waypoints.add(waypoint1);
waypoints.add(waypoint2);
waypoints.add(waypoint3);
WaypointPropagator propagator = new WaypointPropagator(earth, waypoints);
// The propagator can then be used to create a Point that represents the position and velocity of the
// vehicle moving between the waypoints.
Point propagatedPoint = propagator.createPoint();
// Or an entire set of ephemeris can be computed at a specified time step.
DateMotionCollection1<Cartesian> ephemeris = propagator.propagate(waypoint1.getDate(), waypoint3.getDate(), Duration.fromSeconds(60.0), 1,
propagator.getReferenceFrame());
Modifier | Constructor and Description |
---|---|
|
WaypointPropagator(CentralBody centralBody,
Collection<Waypoint> waypoints)
Initializes a waypoint propagator.
|
|
WaypointPropagator(CentralBody centralBody,
Waypoint... waypoints)
Initializes a waypoint propagator.
|
protected |
WaypointPropagator(WaypointPropagator existingInstance,
CopyContext context)
Initializes a new instance as a copy of an existing instance.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkForSameDefinition(CartesianOnePointPropagator other)
Checks to determine if another instance has the same definition as this instance and
returns
true if it does. |
protected boolean |
checkForSameDefinition(WaypointPropagator other)
Checks to determine if another instance has the same definition as this instance and
returns
true if it does. |
Object |
clone(CopyContext context)
Clones this object using the specified context.
|
protected int |
computeCurrentDefinitionHashCode()
Computes a hash code based on the current properties of this object.
|
static WaypointPropagator |
constructConstantVelocityWaypointPropagator(CentralBody centralBody,
List<JulianDate> times,
List<Cartographic> positions)
Creates a waypoint propagator from a list of times and locations.
|
static double |
determineDuration(double displacement,
double initialVelocity,
double finalVelocity)
Assuming constant acceleration, determines the duration from the provided parameters.
|
static double |
determineFinalVelocity(double displacement,
double duration,
double initialVelocity)
Assuming constant acceleration, determines the final velocity from the provided parameters.
|
static double |
determineInitialVelocity(double displacement,
double duration,
double finalVelocity)
Assuming constant acceleration, determines the initial velocity from the provided parameters.
|
void |
enumerateDependencies(DependencyEnumerator enumerator)
Enumerates the dependencies of this object by calling
DependencyEnumerator#enumerate(T) for each object that this object directly depends upon. |
TimeIntervalCollection |
getAvailabilityIntervals()
Gets a
TimeIntervalCollection over which data is available. |
Ellipsoid |
getEllipsoid()
Gets the reference ellipsoid.
|
MotionEvaluator1<Cartesian> |
getEvaluator(EvaluatorGroup group)
|
protected ReferenceFrame |
getMotionReferenceFrame()
Gets the reference frame in which the motion is defined.
|
ReferenceFrame |
getReferenceFrame()
Gets the reference frame in which ephemeris information is produced.
|
TimeInterval |
getTimeInterval()
Gets the time interval over which the propagator can supply ephemeris.
|
List<Waypoint> |
getWaypoints()
Gets the list of waypoints.
|
boolean |
isAvailable(JulianDate date)
Determines if valid data is available for the given
JulianDate . |
checkForSameDefinition, createPoint, getEvaluator, propagate, propagate
areSameDefinition, areSameDefinition, areSameDefinition, areSameDefinition, areSameDefinition, collectionItemsAreSameDefinition, collectionItemsAreSameDefinition, collectionItemsAreSameDefinition, dictionaryItemsAreSameDefinition, freeze, freezeAggregatedObjects, getCollectionHashCode, getCollectionHashCode, getCollectionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDefinitionHashCode, getDictionaryHashCode, getIsFrozen, isSameDefinition, throwIfFrozen
public WaypointPropagator(@Nonnull CentralBody centralBody, @Nonnull Collection<Waypoint> waypoints)
centralBody
- The reference central body.waypoints
- The list of waypoints that define the path and motion.ArgumentNullException
- Thrown when centralBody
or waypoints
is null
.ArgumentException
- Thrown when waypoints
does not contain at least two items.ArithmeticException
- Thrown when the waypoint collection does not model constant accelerations between the waypoints.public WaypointPropagator(@Nonnull CentralBody centralBody, @Nonnull Waypoint... waypoints)
centralBody
- The reference central body.waypoints
- The list of waypoints that define the path and motion.ArgumentNullException
- Thrown when centralBody
or waypoints
is null
.ArgumentException
- Thrown when waypoints
does not contain at least two items.ArithmeticException
- Thrown when the waypoint collection does not model constant accelerations between the waypoints.protected WaypointPropagator(@Nonnull WaypointPropagator existingInstance, @Nonnull CopyContext context)
See ICloneWithContext.clone(CopyContext)
for more information about how to implement this constructor
in a derived class.
existingInstance
- The existing instance to copy.context
- A CopyContext
that controls the depth of the copy.ArgumentNullException
- Thrown when existingInstance
or context
is null
.public Object clone(CopyContext context)
This method should be implemented to call a copy constructor on the class of the
object being cloned. The copy constructor should take the CopyContext
as a parameter
in addition to the existing instance to copy. The copy constructor should first call
CopyContext.addObjectMapping(T, T)
to identify the newly constructed instance
as a copy of the existing instance. It should then copy all fields, using
CopyContext.updateReference(T)
to copy any reference fields.
A typical implementation of ICloneWithContext
:
public static class MyClass implements ICloneWithContext {
public MyClass(MyClass existingInstance, CopyContext context) {
context.addObjectMapping(existingInstance, this);
someReference = context.updateReference(existingInstance.someReference);
}
@Override
public final Object clone(CopyContext context) {
return new MyClass(this, context);
}
private Object someReference;
}
In general, all fields that are reference types should be copied with a call to
CopyContext.updateReference(T)
. There are a couple of exceptions:
If one of these exceptions applies, the CopyContext
should be given an opportunity
to update the reference before the reference is copied explicitly. Use
CopyContext.updateReference(T)
to update the reference. If CopyContext.updateReference(T)
returns
the original object, indicating that the context does not have a replacement registered,
then copy the object manually by invoking a Clone method, a copy constructor, or by manually
constructing a new instance and copying the values.
alwaysCopy = context.updateReference(existingInstance.alwaysCopy);
if (existingInstance.alwaysCopy != null && alwaysCopy == existingInstance.alwaysCopy) {
alwaysCopy = (AlwaysCopy) existingInstance.alwaysCopy.clone(context);
}
If you are implementing an evaluator (a class that implements IEvaluator
), the
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
method shares some responsibilities with the
copy context constructor. Code duplication can be avoided by doing the following:
CopyContext.updateReference(T)
. You should still call CopyContext.updateReference(T)
on any references to
non-evaluators.
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
as the last line in the constructor and pass it the
same CopyContext
passed to the constructor.
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
as normal. See the reference documentation for
IEvaluator.updateEvaluatorReferences(agi.foundation.infrastructure.CopyContext)
for more information on implementing that method.
public MyClass(MyClass existingInstance, CopyContext context) {
super(existingInstance, context);
someReference = context.updateReference(existingInstance.someReference);
evaluatorReference = existingInstance.evaluatorReference;
updateEvaluatorReferences(context);
}
@Override
public void updateEvaluatorReferences(CopyContext context) {
evaluatorReference = context.updateReference(evaluatorReference);
}
@Override
public Object clone(CopyContext context) {
return new MyClass(this, context);
}
private Object someReference;
private IEvaluator evaluatorReference;
clone
in interface ICloneWithContext
clone
in class DefinitionalObject
context
- The context to use to perform the copy.protected final boolean checkForSameDefinition(CartesianOnePointPropagator other)
true
if it does. Derived classes MUST override this method and check
all new fields introduced by the derived class for definitional equivalence. It is NOT necessary
to check base class fields because the base class will already have done that. When overriding this method,
you should NOT call the base implementation because it will return false
for all derived-class instances.
Derived classes should check the type of other
to preserve the symmetric nature of IEquatableDefinition.isSameDefinition(java.lang.Object)
.checkForSameDefinition
in class CartesianOnePointPropagator
other
- The other instance to compare to this one.true
if the two objects are defined equivalently; otherwise false
.protected boolean checkForSameDefinition(WaypointPropagator other)
true
if it does. Derived classes MUST override this method and check
all new fields introduced by the derived class for definitional equivalence. It is NOT necessary
to check base class fields because the base class will already have done that. When overriding this method,
you should NOT call the base implementation because it will return false
for all derived-class instances.
Derived classes should check the type of other
to preserve the symmetric nature of IEquatableDefinition.isSameDefinition(java.lang.Object)
.other
- The other instance to compare to this one.true
if the two objects are defined equivalently; otherwise false
.protected int computeCurrentDefinitionHashCode()
WaypointPropagator.checkForSameDefinition(agi.foundation.propagators.CartesianOnePointPropagator)
method.computeCurrentDefinitionHashCode
in class CartesianOnePointPropagator
public void enumerateDependencies(DependencyEnumerator enumerator)
DependencyEnumerator#enumerate(T)
for each object that this object directly depends upon.
Derived classes which contain additional dependencies MUST override this method, call the base
implementation, and enumerate dependencies introduced by the derived class.enumerateDependencies
in interface IEnumerateDependencies
enumerateDependencies
in class DefinitionalObject
enumerator
- The enumerator that is informed of the dependencies of this object.public final boolean isAvailable(@Nonnull JulianDate date)
JulianDate
.date
- The date for which to check availability.true
if valid data is available for this date; otherwise false
.public static double determineFinalVelocity(double displacement, double duration, double initialVelocity)
displacement
- The total displacement between the initial and final points (distance).duration
- The total duration between the initial and final points (time).initialVelocity
- The velocity at the initial point (distance per time).public static double determineInitialVelocity(double displacement, double duration, double finalVelocity)
displacement
- The total displacement between the initial and final points (distance).duration
- The total duration between the initial and final points (time).finalVelocity
- The velocity at the final point (distance per time).public static double determineDuration(double displacement, double initialVelocity, double finalVelocity)
displacement
- The total displacement between the initial and final points (distance).initialVelocity
- The velocity at the initial point (distance per time).finalVelocity
- The velocity at the final point (distance per time).@Nonnull public static WaypointPropagator constructConstantVelocityWaypointPropagator(@Nonnull CentralBody centralBody, @Nonnull List<JulianDate> times, @Nonnull List<Cartographic> positions)
centralBody
- The reference central body.times
- The list of times the point will be at the given positions
.positions
- The list of positions the point will be at the given times
.ArgumentNullException
- Thrown when centralBody
, times
, or positions
is null
.ArgumentException
- Thrown when the times
and positions
lists have different numbers of elements,
or do not contain at least two items each.public MotionEvaluator1<Cartesian> getEvaluator(EvaluatorGroup group)
Waypoints
(get
) using great arcs across the reference Ellipsoid
(get
) shape model.
The resulting evaluator will produce the Cartesian
position
for a given JulianDate
within the range of the waypoint data represented by TimeInterval
(get
).
The evaluator will throw a DataUnavailableException
when evaluated at
dates before the initial waypoint and after the final waypoint.
getEvaluator
in class CartesianOnePointPropagator
group
- The group with which to associate the new evaluator. By grouping evaluators
that are often evaluated at the same Julian dates, common computations can be performed only once
for the entire group instead of multiple times for each evaluator.ArgumentNullException
- Thrown when group
is null
.CartesianOnePointPropagator.createPoint()
@Nonnull public final TimeInterval getTimeInterval()
public final ReferenceFrame getReferenceFrame()
protected ReferenceFrame getMotionReferenceFrame()
getMotionReferenceFrame
in class CartesianOnePointPropagator
public final Ellipsoid getEllipsoid()
public final TimeIntervalCollection getAvailabilityIntervals()
TimeIntervalCollection
over which data is available.
If the availability interval is infinite, this returns
Infinite
(get
).
It is recommended that you call WaypointPropagator.isAvailable(agi.foundation.time.JulianDate)
to determine availability instead of
calling this method and checking for yourself.