I return a negative value when calculating the solar altitude angle, I don’t know why.
This is my fanction:
public double getSunElevation(GeodeticPoint nadirPoint, AbsoluteDate currentDate) {
TopocentricFrame topoFrame = new TopocentricFrame(earth, nadirPoint, “topo”);
TimeStampedPVCoordinates sunInTopo = sun.getPVCoordinates(currentDate, topoFrame);
Vector3D sunDirection = sunInTopo.getPosition();
double elevation = FastMath.asin(sunDirection.getZ() / sunDirection.getNorm());
return FastMath.toDegrees(elevation);
}
luc
July 9, 2026, 9:01am
2
Note that TopocentricFrame already has a builtin getElevation method.
May be the Sun is below horizon at this date?
Yes, I used
double sunEvelation = topoFrame.getElevation(sunDirection, topoFrame, currentDate);
and got the same value, can I simpled to abs it?
xzguo
July 10, 2026, 2:53am
4
A negative sun elevation angle means the Sun is below the local horizon; it has nothing to do with taking absolute or not. If you’re certain the Sun is above the local horizon at this time, you should recheck your code.