Transforming geodetic points to spacecraft body frame

Hello Orekit community,

Is there a way to transform a set of geodetic points to spacecraft body frame at the specific time so that i can obtain satellite field of view?

Thanks in advance
Suleyman

Hello @saltinisik,

What you’re trying to achieve looks very much like what @Echulion already asked for at the end of this thread.
Am I right @Echulion ?

I will try to answer, hoping that I can help the both of you.

Suppose you have a SpacecraftState state and a GeodeticPoint geoPoint.

// Get the reference frame of the SpacecraftState (the inertial frame where the orbit is computed)
Frame refFrame = state.getFrame();

// Get the position of the SpacecraftState in ref frame
Vector3D satPosInRefFrame = state.getPVCoordinates().getPosition();

// Get its date
AbsoluteDate date = state.getDate();

// Get the attitude of the spacecraft (a rotation from reference frame to "satellite" frame)
Attitude attitude = state.getAttitude();

// Get the underlying topocentric frame of the geodetic point
TopocentricFrame topoFrame = new TopocentricFrame(earth, geoPoint, "topoFrame");

// Get the geodetic point position in reference frame
Vector3D geoPointInRefFrame = topoFrame.getPVCoordinates(date, refFrame).getPosition();

// Let O be the center of frame, S the satellite and P the geodetic point
// Compute satellite to geodetic point vector: SP = - OS + OP
Vector3D sat2GeoPoint = geoPointInRefFrame.subtract(satPosInRefFrame);

// Normalize the vector and rotate it using the attitude
Vector3D geoPointDirectionInSatFrame = attitude.getRotation().applyTo(sat2GeoPoint.normalize());

With this you should have the geodetic point direction in satellite frame (i.e. a unit vector pointing to the geodetic point with respect to the satellite position and attitude).

Is that what you are looking for ?

Maxime

1 Like

Hello @MaximeJ,

Yes you are definitely right. The problem defined here is really similar to what I am trying to achieve. I implemented the code you’ve shared in my ipynb. notebook. I believe this algorithm is correct and this should give us the the points in the frame of the spacecraft.

Yet… Still, for some reason the polygonal shape differs from what I wish to see. Here is a visual depiction of what I am seeing:

  • I entered the geodetic coordinates of the polygon I wish to get at the initial date-time. I want to get the blue FoV drawn in the figure.
  • I convert these geodetic coordinates to the spacecraft frame thanks to the code you have provided.
  • Then entered these “converted” coordinates to the SphericalPolygonsSet which is required inside the PolygonalFieldOfView method.
  • Finally checking the FoV if I did it correct or not. The output FoV appears to be something like the red FoV I have depicted above.

So it is both scaled down and moved diagonally. I think this is something related to frame conversions, but then again the code you have provided should’ve solved this issue. So this is rather peculiar and I am at lost to be honest.

Hi @Echulion,

Maybe the code I gave you is not perfect, I wrote this very quickly.
Could you provide a code with what you have and what you expect ?

Greetings @MaximeJ ,

I’ve been trying different stuff in the meantime and the thing is, the problem is actually solved! I have done a very trivial fix to correct this issue but before diving into that, I would like to thank you sincerely, for your lasting support in this problem :slight_smile:

First of all, the algorithm you have provided above works perfectly well. This is what should be done to convert geodetic points to spacecraft frame. In the case of creating a PolygonalFieldOfView one must use this algorithm as well since we are supposed to create this polygon in the s/c frame.

Before using this algorithm one must define the polygon in clockwise manner. This solved the issue for me.

What was my mistake: I though we should define the polygon FoV just as we defined the area-of-interest on the surface of earth, which is in counter clockwise manner. This was the culprit.

Since the problem is solved here, I will adress this post in the other one.

Thanks again!

Greetings @Echulion,

I’m glad to see you managed to solve your problem. And you are very welcome for the help !

Interesting, did you find an explanation in Hipparchus javadoc or did you come up with this through trial and error ?

No, I did not find any explanation in Hipparchus javadoc, although when defining a zone on the surface of the earth, “counter clockwise manner” is mentioned couple times, that is why I assumed drawing the polygonal FoV would be similar.

In the other post, I’ve mentioned a code snipped about checking the initial footprint within the propagation:

initialCartesianOrbit = CartesianOrbit(SGP4_pv, ECI, initialDate, Mu_earth)
state = SpacecraftState(initialCartesianOrbit, satellite_mass)
inertToBody = state.getFrame().getTransformTo(earth.getBodyFrame(), state.getDate())
fovToBody = Transform(state.getDate(),
                      state.toTransform().getInverse(),
                      inertToBody)
footprint = imagerFOV1.getFootprint(fovToBody, earth, radians(10.0))
footPrintList.append(footprint)

After applying your algorithm, this bit gave me lat/long coordinates very close to what I have aimed to get at the first place… And I noticed that they were somewhat in backwards order. Then, I tried to enter the geodetic point set I have in clockwise order, and voilà! Issue is solved with trial and error, per se. :partying_face:

Hi @MaximeJ and @Echulion ,

First of all thank you for the code that you snipped both of you @MaximeJ and @Echulion , i tried my code with your solutions and it works perfect for me.

Thank you very much orekit community, whenever i stuck any problem, this forum always helped me!

Suleyman

You’re very welcome @saltinisik, we’re always happy to help !