Get angle between a TopocentricFrame and a propagated SpaceCraftState

I have been trying to calculate the angle and distance of a satellite (SpaceCraftState) from a GeodeticPoint nested in a topocentric frame, by using
TopocentricFrame is c
SpaceCraftState is s
FastMath.toDegrees(c.getElevation(s.getPVCoordinates().getPosition(),c,s.getDate())); but when i calculated the distance between these two points i get missmatching data, eg. distance of 2900 km with an elevation degree of 59 when the elevation between the satellite and earth is 1000 km. Am is missing something or using a bad approach?

Thanks in advance!
Narcano

Hi @Narcano

Welcome to the Orekit forum!

The problem is that you are assuming that the spacecraft’s position is given in topocentric frame. However, I don’t think that you used TopocentricFrame as the reference frame of the spacecraft’s orbit. I would recommend you to directly use s.getFrame() when defining the spacecraft frame in getElevation() method. Indeed, the frame argument of this method is the frame in which the position is defined. So, by using s.getFrame() you are at 100% sure to have the good one. :slight_smile:

You can therefore easily calculate the elevation and azimuth angles of the spacecraft from the topocentric frame using:

// compute elevation
final double elevation = FastMath.toDegrees(c.getElevation(s.getPVCoordinates().getPosition(), s.getFrame(), s.getDate()));

// compute azimuth
final double azimuth = FastMath.toDegrees(c.getAzimuth(s.getPVCoordinates().getPosition(), s.getFrame(), s.getDate()));

In addition, to have the distance of the satellite from your station the easiest solution in your situation (i.e., with a topocentric frame and a spacecraft state) is to use c.getRange(). Please find an example below

// compute range
final double range = c.getRange(s.getPVCoordinates().getPosition(), s.getFrame(), s.getDate());

I hope these comments will help you.

Best regards,
Bryan
.

1 Like

Hi @bcazabonne!

Thank you for the reply!
I implemented these changes and i found something interesting: using c.getRange() and
c.getElevation() gives me wildly different outputs then when working with the PVcoordinates got from each element. Can this be due me creating the topocentric frame with:
final BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, earthFrame); final GeodeticPoint station1 = new GeodeticPoint(city.latitude, city.longitude, city.altitude); final TopocentricFrame sta1Frame = new TopocentricFrame(earth, station1, c.name);

For example:
double distance = coord.distance(s.getPVCoordinates().getPosition()); = 1.101832597863436E7
double distance1 = c.getRange(s.getPVCoordinates().getPosition(), s.getFrame(), s.getDate()); = 2108729.987698398

Or with the elevation angles:
double degree1 = FastMath.toDegrees(c.getElevation(s.getPVCoordinates().getPosition(), s.getFrame(), s.getDate())); = 20.009155962863076
while
double degree = FastMath.toDegrees(FastMath.asin((s.getPVCoordinates().getPosition().distance(Vector3D.ZERO)-coord.distance(Vector3D.ZERO))/distance)); = 5.183651337547434

Can the problem be the diference between reference frames?

Thank you in advance,
Andrew

Can you give me the eccentricity and the semi-major axis of the orbit? It is just to verify if one the two outputs if physically unacceptable.
However, if coord and s.getPVCoordinates().getPosition() are not defined in the same frame, the result of coord.distance(s.getPVCoordinates().getPosition()); is wrong.

Here, I think you are working with two different frames too.

Yes it is. When calculating distance or angles it is very important to work with the same frame (i.e., the same reference for the coordinates). Generally, it is the case every time we work on coordinates of different bodies. When frames are different, for instance with an orbit frame and a topocentric frame, it is very important to do the transformation allowing to do the calculations on the same one. The getElevation() and getRange() methods perform these transformations.Therefore, I trust the results given by these two methods.

Bryan

Thank you very much!

You were right it shouldnt be possible, semi major axis is = 1000 km while eccentricity is 0.0002