Click or drag to resize

Reference Frames and Transformations

This topic builds upon the foundation of geometrical and coordinate primitives discussed in the Axes, Points, and Vectors and Coordinates topics. To begin, we define the geometrical concept of a ReferenceFrame as a location point (origin) and a set of axes. A common example of a reference frame is the Earth's fixed frame, EarthCentralBodyFixedFrame. In this frame, the Point defining the origin is at the center of mass of the Earth and the Axes are aligned such that (in Cartesian coordinates) the Z-axis is pointed North and the X-axis intersects the surface at 0 latitude, 0 longitude. The Y-axis is then defined by the right-hand rule.

Transforming Geometry

GeometryTransformer allows you to easily transform between geometry components by following the chain of relationships between them. One of the primary uses of the transformer is to allow the user to switch between two reference frames. The following example shows how to obtain an evaluator for the transformation between the Earth fixed and Earth inertial reference frames and use it to find an equivalent inertial vector for a given fixed vector:

C#
// Get the Earth central body and assign Earth Orientation Parameters loaded from
// the specified EOP data file.
EarthCentralBody earth = CentralBodiesFacet.GetFromContext().Earth;
earth.OrientationParameters = EarthOrientationParametersFile.ReadData(eopPath);

// Get an evaluator to transform from the fixed to inertial frames, and evaluate it
// at 'now' to get the actual transformation.
ReferenceFrameEvaluator evaluator =
    GeometryTransformer.GetReferenceFrameTransformation(earth.FixedFrame, earth.InertialFrame);
KinematicTransformation transformation = evaluator.Evaluate(JulianDate.Now, 0);

// Use the transformation to transform a vector in the fixed frame to the inertial frame.
Cartesian fixedVectorToTransform = new Cartesian(1.0, 2.0, 3.0);
Cartesian equivalentInertialVector = transformation.Transform(fixedVectorToTransform);

Each geometry component is defined relative to another geometry component. A Point is defined in a ReferenceFrame. A Vector is defined in a set of Axes. A set of Axes or a ReferenceFrame is defined in terms of another set of Axes or a ReferenceFrame, respectively. However, each Point is not necessarily defined in terms of the same ReferenceFrame all the time. For example, the Point representing a spacecraft traveling toward the Moon may initially be defined in an Earth-centered ReferenceFrame. As it gets closer to the Moon, it may switch to a Moon-centered ReferenceFrame. To handle this, the geometry components' evaluators have a property called DefinedInIntervals which identifies the ReferenceFrame or Axes in which the component is defined over that interval. In the case of the interplanetary trajectory, the DefinedInIntervals collection contains two TimeInterval<ReferenceFrame> objects. The first holds the Earth-centered ReferenceFrame in its Data property, and the second holds the Moon-centered ReferenceFrame as its Data. The first interval stops at the same time the second interval starts, with the IsStartIncluded and IsStopIncluded properties of the TimeInterval<ReferenceFrame> indicating which system is used at that time. This allows a single geometry component to be defined in different systems at different times.

In general, it is best to use the GeometryTransformer to observe the geometry in the desired system. However, to find the Axes or ReferenceFrame in which a component is defined at a given time, call the FindIntervalContainingDate method with the JulianDate used to evaluate the component. Then, get the Data property of the TimeInterval<T>.

Each geometry component knows how to evaluate itself with respect to the components held in DefinedInIntervals. For example, if a PointEvaluator is defined in the Earth fixed frame, then calling Evaluate will return the position and its derivatives with respect to the Earth fixed frame. To obtain the position, velocity, acceleration, etc. with respect to the Earth inertial frame instead, use the GeometryTransformerObservePoint method, as shown in the next example.

C#
// Get the Earth central body and assign Earth Orientation Parameters loaded from
// the specified EOP data file.
EarthCentralBody earth = CentralBodiesFacet.GetFromContext().Earth;
earth.OrientationParameters = EarthOrientationParametersFile.ReadData(eopPath);

// Create a point at a fixed location with respect to the Earth fixed reference frame.
PointFixedOffset point = new PointFixedOffset(earth.FixedFrame, new Cartesian(8000000.0, 0.0, 0.0));

// Get an evaluator which can transform the point into the Earth inertial 
// reference frame at a given time.
PointEvaluator evaluator = GeometryTransformer.ObservePoint(point, earth.InertialFrame);

// Evaluate the evaluator 'now'.  The point is stationary with respect to the fixed frame, but
// it is moving with respect to the inertial frame.
Motion<Cartesian> positionAndVelocity = evaluator.Evaluate(JulianDate.Now, 1);

For a Point, the GeometryTransformer follows the chains created by the ReferenceFrame in the DefinedInIntervals to determine the shortest sequence of transformations between any two geometry components. In general, whenever creating an evaluator to evaluate vector geometry, it is best to get the evaluator through the GeometryTransformer rather than calling GetEvaluator on a particular geometry component itself. This ensures that the evaluator computes the geometry in the expected reference system.

Lastly, new geometry components can be easily added by deriving from Axes, Point, or Vector and creating the corresponding AxesEvaluator, PointEvaluator, or VectorEvaluator respectively. These user-defined components can then participate in GeometryTransformer transformations and other geometry types just like the existing components included with DME Component Libraries.

The geometry components can be found in the AGI.Foundation.Geometry namespace.

International Terrestrial Reference Frames

International Terrestrial Reference Frames (ITRFs) are realizations of the fixed frame of the Earth that are updated periodically by the International Earth Rotation and Reference Systems Service (IERS) to account for plate tectonics and other geophysical phenomena. Because ITRFs have different transformation rules than other ReferenceFrames, converting between ITRFs requires the use of InternationalTerrestrialReferenceFrameTransformers. These transformers require the correct configuration of updated EarthOrientationParameters.

C#
EarthCentralBody earth = CentralBodiesFacet.GetFromContext().Earth;
EarthOrientationParameters eop = EarthOrientationParametersFile.ReadData(Path.Combine(dataPath, "EOP-v1.1.txt"));
earth.OrientationParameters = eop;

// The EarthOrientationParameters of the EarthCentralBody
// determine which ITRF is the same as the FixedFrame of the
// Earth. By default, this will be the ITRF2020 unless the EarthOrientationParameters
// specify otherwise.
string nativeItrfFrame = eop.NativeItrfFrame;
ReferenceFrame itrf2020Frame = earth.FixedFrame;

There are a number of ways of using ITRF transformers. A possible use case could be the following. Let's say that we have a collection of data in the ITRF2014 frame and we want to transform the collection into the ITRF2020 frame.

C#
// First, get the available transformation definitions.
List<InternationalTerrestrialReferenceFrameTransformer> itrfList
    = InternationalTerrestrialReferenceFrameTransformer.ItrfDefinitions;

// Second, use GetFirstFromList to get the ITRF2014 to ITRF2020 frame transformation.
var itrf2014ToItrf2020
    = InternationalTerrestrialReferenceFrameTransformer.GetFirstFromList(itrfList, "ITRF2014", "ITRF2020");

// Third, transform the collection.
DateMotionCollection<Cartesian> itrf2020Collection = itrf2014ToItrf2020.TransformCollection(itrf2014Collection);

Let's say that instead of transforming the data to create a new collection, we want to create a PointInterpolator from the data. The only ITRF that is also a ReferenceFrame is ITRF2020, which is the fixed frame for the loaded EOP file. CreatePointInterpolatorInFixedFrame internally transforms the data into the ITRF2020 frame and then creates a point interpolator in the ITRF2020/fixed frame.

C#
const int interpolationDegree = 5;
var pointInterpolator
    = InternationalTerrestrialReferenceFrameTransformer.CreatePointInterpolatorInFixedFrame(earth,
                                                                                            itrf2014ToItrf2020,
                                                                                            "ITRF2014",
                                                                                            new LagrangePolynomialApproximation(),
                                                                                            interpolationDegree,
                                                                                            itrf2014Collection);

Points can only be defined in reference frames and the only ITRF frame that is also a ReferenceFrame is the one that is equivalent to the FixedFrame of the Earth, which is currently ITRF2020 by default. ConvertPoint can be used to apply ITRF transformations to convert a point from the ITRF2020 to another ITRF.

C#
Point pointItrf2014
    = InternationalTerrestrialReferenceFrameTransformer.ConvertPoint(earth, pointItrf2020, "ITRF2014");

// The converted point can be used to create a collection of ephemeris in the
// ITRF2014 frame. The point still needs to be observed in the ITRF2020 frame,
// but any data it provides will be correctly transformed into the ITRF2014 frame.
var group = new EvaluatorGroup();
PointEvaluator evaluator = GeometryTransformer.ObservePoint(pointItrf2014, itrf2020Frame, group);
DateMotionCollection<Cartesian> newItrf2014Collection = new DateMotionCollection<Cartesian>();

foreach (var date in dates)
{
    Motion<Cartesian> convertedData = evaluator.Evaluate(date, 1);
    newItrf2014Collection.Add(date, convertedData);
}