Transforming Angles

Newbie question here.

Are there any good examples out there transforming AngularRaDec from one coordinate system to another. I would like to go back-and-forth from TEMEofDate to EME2000

Thx

Hi @Joe,

I would say something along these lines:

    public AngularRaDec transformReferenceFrame(AngularRaDec original, Frame newFrame) {
        Transform t                   = original.getReferenceFrame().getTransformTo(newFrame, original.getDate());
        double[] originalAngles       = original.getObservedValue();
        Vector3D originalDirection    = new Vector3D(originalAngles[0], originalAngles[1]);
        Vector3D transformedDirection = t.transformVector(originalDirection);
        double[] transformedAngles    = new double[] {
             transformedDirection.getAlpha(),
             transformedDirection.getDelta()
        };
       return new AngularRaDec(original.getStation(), newFrame, original.getDate(),
                               transformedAngles, original.getSigma(), original.getWeight(),
                               original.getSatellites().get(0));
    }

Note however that even if you want your orbit determination process to compute orbits in TEME (by configuring the underlying propagator builder) and your measurements were created in EME2000, it will work properly. The measurement is aware of both the spacecraft state frame and of its own frame and does compute the transform internally, so you don’t need to convert the measurement beforehand. It also works the other way round, if your measurements were created in TEME and you want to compute orbits in EME2000, just use the available measurements as is and let the transform be performed automatically under the hood.

The use case here is that we are getting B3 obs from some of the older sensor systems in TEMEofDate. We want to combine them with other observations decks that are already in EME2000. Then we will post to our database before consuming in an IOD/OD tool, so the converted frame is the end product.

[SOLUTION]

For those that may want to solve this in the future… I believe this is the solution. (giving back to the community)

//
// initialisation
//

    //Define Site Location
    double siteLatRad = Math.toRadians(39.2799);
    double siteLonRad = Math.toRadians(-104.773);
    double siteAltMeters = 2019.96; // Meters
    double ra = Math.toRadians(30.838);
    double dec = Math.toRadians(22.167);
    double[] raDecAngular = {ra, dec};
    AbsoluteDate obsTime = new AbsoluteDate(2019, 10, 12, 06, 46, 18.849, TimeScalesFactory.getUTC());
    String stationName = "ConversionSite";

    // Set up all the constructors

    // define Earth shape, using WGS84 model
    BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
            Constants.WGS84_EARTH_FLATTENING,
            FramesFactory.getITRF(IERSConventions.IERS_2010, false));

    // define an array of ground stations
    TopocentricFrame station =
            new TopocentricFrame(earth, new GeodeticPoint(siteLatRad, siteLonRad, siteAltMeters), stationName);

    GroundStation groundStation = new GroundStation(station);

    // inertial frame
    Frame inertialFrame = FramesFactory.getEME2000();
    Frame temeFrame = FramesFactory.getTEME();

    // Preparing the code for Luc
    final double[] sigma = {0,0};
    final double[] baseWeight = {0,0};
    AngularRaDec original = new AngularRaDec(groundStation, temeFrame, obsTime, raDecAngular, sigma, baseWeight, new ObservableSatellite(0));

    // Lucs code
    Transform t                   = original.getReferenceFrame().getTransformTo(inertialFrame, original.getDate());
    double[] originalAngles       = original.getObservedValue();
    Vector3D originalDirection    = new Vector3D(originalAngles[0], originalAngles[1]);
    Vector3D transformedDirection = t.transformVector(originalDirection);
    double[] transformedAngles    = new double[] {
            transformedDirection.getAlpha(),
            transformedDirection.getDelta()
    };
    AngularRaDec newAngle =  new AngularRaDec(original.getStation(), inertialFrame, original.getDate(),
            transformedAngles, sigma, baseWeight,
            original.getSatellites().get(0));

    double asd[] = newAngle.getObservedValue();
    double raDeg = Math.toDegrees(asd[0]);
    double decDeg = Math.toDegrees(asd[1]);