S2Point Definitions

This is a follow-on from my other post (PolygonalFieldOfView). I’m struggling with an issue with the S2Point definition and how they are generated from a Vector3D versus an azimuth and elevation (or phi and theta values). Essentially I have a satellite / sensor geometry that is the following:

// Satellite Definition (in EMEJ2000)
AbsoluteDate epoch = new AbsoluteDate(2023, 9, 20, 5, 2, 54.709023, TimeScalesFactory.getUTC());
Vector3D posJ2K = new Vector3D(12135768.157731938, 40380634.83937937, -38113.4611490222);

// Sensor Location / Frame Definition
GeodeticPoint senLoc = new GeodeticPoint(Math.toRadians(35.07047), Math.toRadians(25.97262), 418.0);
TopocentricFrame senTopo = new TopocentricFrame(earth, senLoc, "TEST_SITE");

From this I’m able to compute the azimuth and elevation values directly using this method:

Frame j2k = FramesFactory.getEME2000();
double satAz = Math.toDegrees(senTopo.getAzimuth(posJ2K, j2k, epoch));
double satEl = Math.toDegrees(senTopo.getElevation(posJ2K, j2k, epoch));

Now, if I use the azimuth and elevation to compute an S2Point to be used in a checkPoint() within a SphericalPolygonsSet, I get the correct results and it shows that I am within the bounds of the set.

S2Point satPoint = SensorUtils.azElToS2Point(satAz, satEl);
SphericalPolygonsSet sps = new SphericalPolygonsSet(...)
Location loc = sps.checkPoint(satPoint);

If I then try to define an S2Point using the same Vector3D but as a cartesian state transformed into the topocentric frame, then I get a situation where it looks like the X and Y component of the unit vector contained within the S2Point are reversed

J2KToTopo = j2k.getTransformTo(senTopo,epoch);
Vector3D posTopo = J2KToTopo.transformPosition(posJ2K);
S2Point satPoint2 = new S2Point(posTopo);
Location loc2 = sps.checkPoint(satPoint2);

The results show that loc = INSIDE, and loc2 = OUTSIDE. The vectors for each are this:

satPoint.vector = [x: -0.571553, y: -0.506316, z: 0.645733]
satPoint2.vector = [x: -0.506316, y: -0.571553, z: 0.645733]

Both start with the same J2K vector, but are producing different results leading me to think that there might be something I’m not understanding about this process. I think once this is resolved I should be able to see correct behavior out of my PolygonFieldOfView objects, which I’m not able to get working at the moment due to this issue. Any help you can provide would be greatly appreciated!


Topocentric frames uses the classical convention that azimuth is counted from the North towards the East, i.e. North is at azimuth 0, East at azimuth π/2, South at azimuth π and West at azimuth 3π/2. At the same time, the X axis of the topocentric frame is towards East, the Y axis is towards North and the Z axis is towards Zenith.

So the culprit is probably that azimuth 0 is not along the X axis.

S2Point on the other hand follows mathematical convention and has nothing to do with topocentric frames. Here the θ angle is from X to Y and the φ angle is from Z to (X,Y) plane.

So θ and the azimuth from topocentric frame are not interchangeable.

@luc thanks for the quick response! That makes sense, although what is expected for the usage of PolygonalFieldOfView when it requires the input Vector3D lineOfSight variable? From what I can tell, it would only work if you defined your vector based on the mathematical convention… is that correct?