This is the first in what I hope will be a series of short "how to" articles on accomplishing specific tasks with AGI Components.
In this article, I will show how to use Dynamic Geometry Library to compute the rotation between the Earth Centered Fixed (ECF) and Earth Centered Inertial (ECI) reference frames.
In the image above, the red lines represent the ECF reference frame while the blue lines represent the ECI reference frame. Given a point or vector defined in one of the reference frames, we can find it in the other reference frame. It's important to note that the ECI and ECF frames moves with respect to each other. So a point that is stationary in the ECI frame is moving in the ECF frame, and vice-versa.
We'll need the following
using declarations for the code to follow:
using AGI.Foundation.Coordinates; using AGI.Foundation.Celestial; using AGI.Foundation.Geometry; using AGI.Foundation.Time;
Dynamic Geometry Library's
ReferenceFrame class represents a reference frame. Various predefined reference frames can be obtained from the central body instances in the CentralBodiesFacet. So, our first step is to obtain the Earth:
EarthCentralBody earth = CentralBodiesFacet.GetFromContext().Earth;
Next, we obtain the ECF and ECI reference frames from the Earth instance:
ReferenceFrame ecf = earth.FixedFrame; ReferenceFrame eci = earth.InertialFrame;
The GeometryTransformer static class will help us obtain an evaluator for transforming between the two reference frames. In this case, we want a transformation from the ECF frame to the ECI frame:
ReferenceFrameEvaluator evaluator = GeometryTransformer.GetReferenceFrameTransformation(ecf, eci);
Because these two references frames move relative to each other, the transformation between them changes with time. So we must evaluate the transformation at a specific time:
JulianDate now = new JulianDate(DateTime.UtcNow); KinematicTransformation transformation = evaluator.Evaluate(now);
Cartesian somePositionEcf = new Cartesian(9127571.4, 8009590.78, 7325222.9); Cartesian somePositionEci = transformation.Transform(somePositionEcf);
KinematicTransformation contains both the rotational and translational components of the transformation. Since the ECF and ECI frames are both centered at Earth's center of mass, there is no translational component. The
Rotation property provides just the rotation between the frames, and it can easily be converted to other rotational transformation representations support by Dynamic Geometry Library:
UnitQuaternion rotation = transformation.Rotation; Matrix3By3 rotationAsMatrix = new Matrix3By3(rotation);
For more information, see the Reference Frames and Transformations overview in the documentation.