Skip to content

Commit

Permalink
chore: minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
klausbrunner committed Dec 2, 2023
1 parent a4e20df commit fff3b16
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/main/java/net/e175/klaus/solarpositioning/SPA.java
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,17 @@ private static SolarPosition calculateTopocentricSolarPosition(
// calculate topocentric zenith angle
final double eZero =
asin(sin(phi) * sin(deltaPrime) + cos(phi) * cos(deltaPrime) * cos(hPrime));
final double topocentricZenithAngle = calculateTopocentricZenithAngle(p, t, eZero);

// Calculate the topocentric azimuth angle
final double gamma = atan2(sin(hPrime), cos(hPrime) * sin(phi) - tan(deltaPrime) * cos(phi));
final double gammaDegrees = limitDegreesTo360(toDegrees(gamma));
final double topocentricAzimuthAngle = limitDegreesTo360(gammaDegrees + 180);

return new SolarPosition(topocentricAzimuthAngle, topocentricZenithAngle);
}

private static double calculateTopocentricZenithAngle(double p, double t, double eZero) {
final double eZeroDegrees = toDegrees(eZero);

// refraction correction.
Expand All @@ -535,14 +546,7 @@ private static SolarPosition calculateTopocentricSolarPosition(

final double correctedEZeroDegrees = eZeroDegrees + deltaEdegrees;

final double topocentricZenithAngle = 90 - correctedEZeroDegrees;

// Calculate the topocentric azimuth angle
final double gamma = atan2(sin(hPrime), cos(hPrime) * sin(phi) - tan(deltaPrime) * cos(phi));
final double gammaDegrees = limitDegreesTo360(toDegrees(gamma));
final double topocentricAzimuthAngle = limitDegreesTo360(gammaDegrees + 180);

return new SolarPosition(topocentricAzimuthAngle, topocentricZenithAngle);
return 90 - correctedEZeroDegrees;
}

private static double calculateGeocentricSunDeclination(
Expand Down

0 comments on commit fff3b16

Please sign in to comment.