@@ -67,7 +67,8 @@ public double elevation() {
6767 /**
6868 * Calculate time-dependent parts of the SPA algorithm (steps 1-11). These calculations depend
6969 * only on the date/time and can be computed once for bulk processing at a fixed time with varying
70- * coordinates.
70+ * coordinates. Use with {@link #calculateSolarPositionWithTimeDependentParts} for significant
71+ * performance improvements when calculating positions for multiple coordinates at the same time.
7172 *
7273 * @param date Observer's local date and time.
7374 * @param deltaT Difference between earth rotation time and terrestrial time (or Universal Time
@@ -85,19 +86,19 @@ public static SpaTimeDependent calculateSpaTimeDependentParts(
8586
8687 // calculate Earth heliocentric longitude, L
8788 final double [] lTerms = calculateLBRTerms (jme , TERMS_L );
88- final double lDegrees = limitDegreesTo360 (toDegrees (calculateLBRPolynomial (jme , lTerms )));
89+ final double lDegrees = limitTo (toDegrees (calculateLBRPolynomial (jme , lTerms )), 360 );
8990
9091 // calculate Earth heliocentric latitude, B
9192 final double [] bTerms = calculateLBRTerms (jme , TERMS_B );
92- final double bDegrees = limitDegreesTo360 (toDegrees (calculateLBRPolynomial (jme , bTerms )));
93+ final double bDegrees = limitTo (toDegrees (calculateLBRPolynomial (jme , bTerms )), 360 );
9394
9495 // calculate Earth radius vector, R
9596 final double [] rTerms = calculateLBRTerms (jme , TERMS_R );
9697 final double r = calculateLBRPolynomial (jme , rTerms );
9798 assert r != 0 ;
9899
99100 // calculate geocentric longitude, theta
100- final double thetaDegrees = limitDegreesTo360 (lDegrees + 180 );
101+ final double thetaDegrees = limitTo (lDegrees + 180 , 360 );
101102 // calculate geocentric latitude, beta
102103 final double betaDegrees = -bDegrees ;
103104 final double beta = toRadians (betaDegrees );
@@ -146,7 +147,6 @@ public static SpaTimeDependent calculateSpaTimeDependentParts(
146147 * #calculateSpaTimeDependentParts}. Used together, these provide significant speedup for
147148 * coordinate sweeps at fixed time.
148149 *
149- * @param date Observer's local date and time (must match the date used for timeDependent).
150150 * @param latitude Observer's latitude, in degrees (negative south of equator).
151151 * @param longitude Observer's longitude, in degrees (negative west of Greenwich).
152152 * @param elevation Observer's elevation, in meters.
@@ -161,7 +161,6 @@ public static SpaTimeDependent calculateSpaTimeDependentParts(
161161 * @see SolarPosition
162162 */
163163 public static SolarPosition calculateSolarPositionWithTimeDependentParts (
164- final ZonedDateTime date ,
165164 final double latitude ,
166165 final double longitude ,
167166 final double elevation ,
@@ -176,7 +175,7 @@ public static SolarPosition calculateSolarPositionWithTimeDependentParts(
176175 final double deltaDegrees = timeDependent .deltaDegrees ;
177176
178177 // Calculate observer local hour angle
179- final double hDegrees = limitDegreesTo360 (timeDependent .nuDegrees + longitude - alphaDegrees );
178+ final double hDegrees = limitTo (timeDependent .nuDegrees + longitude - alphaDegrees , 360 );
180179 final double h = toRadians (hDegrees );
181180
182181 // Calculate the topocentric sun right ascension and sun declination
@@ -234,14 +233,13 @@ public static SolarPosition calculateSolarPosition(
234233 final double temperature ) {
235234 final SpaTimeDependent timeDependent = calculateSpaTimeDependentParts (date , deltaT );
236235 return calculateSolarPositionWithTimeDependentParts (
237- date , latitude , longitude , elevation , pressure , temperature , timeDependent );
236+ latitude , longitude , elevation , pressure , temperature , timeDependent );
238237 }
239238
240239 /**
241240 * Calculate topocentric solar position using pre-computed time-dependent parts. This method does
242241 * not perform refraction correction.
243242 *
244- * @param date Observer's local date and time (must match the date used for timeDependent).
245243 * @param latitude Observer's latitude, in degrees (negative south of equator).
246244 * @param longitude Observer's longitude, in degrees (negative west of Greenwich).
247245 * @param elevation Observer's elevation, in meters.
@@ -252,13 +250,12 @@ public static SolarPosition calculateSolarPosition(
252250 * @see SolarPosition
253251 */
254252 public static SolarPosition calculateSolarPositionWithTimeDependentParts (
255- final ZonedDateTime date ,
256253 final double latitude ,
257254 final double longitude ,
258255 final double elevation ,
259256 final SpaTimeDependent timeDependent ) {
260257 return calculateSolarPositionWithTimeDependentParts (
261- date , latitude , longitude , elevation , Double .NaN , Double .NaN , timeDependent );
258+ latitude , longitude , elevation , Double .NaN , Double .NaN , timeDependent );
262259 }
263260
264261 /**
@@ -647,7 +644,7 @@ private static AlphaDelta calculateAlphaDelta(
647644 double jme , double deltaPsi , double epsilonDegrees ) {
648645 // calculate Earth heliocentric latitude, B
649646 final double [] bTerms = calculateLBRTerms (jme , TERMS_B );
650- final double bDegrees = limitDegreesTo360 (toDegrees (calculateLBRPolynomial (jme , bTerms )));
647+ final double bDegrees = limitTo (toDegrees (calculateLBRPolynomial (jme , bTerms )), 360 );
651648
652649 // calculate Earth radius vector, R
653650 final double [] rTerms = calculateLBRTerms (jme , TERMS_R );
@@ -656,10 +653,10 @@ private static AlphaDelta calculateAlphaDelta(
656653
657654 // calculate Earth heliocentric longitude, L
658655 final double [] lTerms = calculateLBRTerms (jme , TERMS_L );
659- final double lDegrees = limitDegreesTo360 (toDegrees (calculateLBRPolynomial (jme , lTerms )));
656+ final double lDegrees = limitTo (toDegrees (calculateLBRPolynomial (jme , lTerms )), 360 );
660657
661658 // calculate geocentric longitude, theta
662- final double thetaDegrees = limitDegreesTo360 (lDegrees + 180 );
659+ final double thetaDegrees = limitTo (lDegrees + 180 , 360 );
663660
664661 // calculate geocentric latitude, beta
665662 final double betaDegrees = -bDegrees ;
@@ -701,8 +698,8 @@ private static SolarPosition calculateTopocentricSolarPosition(
701698
702699 // Calculate the topocentric azimuth angle
703700 final double gamma = atan2 (sin (hPrime ), cosHPrime * sinPhi - tan (deltaPrime ) * cosPhi );
704- final double gammaDegrees = limitDegreesTo360 (toDegrees (gamma ));
705- final double topocentricAzimuthAngle = limitDegreesTo360 (gammaDegrees + 180 );
701+ final double gammaDegrees = limitTo (toDegrees (gamma ), 360 );
702+ final double topocentricAzimuthAngle = limitTo (gammaDegrees + 180 , 360 );
706703
707704 return new SolarPosition (topocentricAzimuthAngle , topocentricZenithAngle );
708705 }
@@ -737,7 +734,7 @@ private static double calculateGeocentricSunRightAscension(
737734 final double alpha =
738735 atan2 (sin (lambdaRad ) * cos (epsilonRad ) - tan (betaRad ) * sin (epsilonRad ), cos (lambdaRad ));
739736
740- return limitDegreesTo360 (toDegrees (alpha ));
737+ return limitTo (toDegrees (alpha ), 360 );
741738 }
742739
743740 private static double calculateTrueObliquityOfEcliptic (
@@ -749,10 +746,11 @@ private static double calculateTrueObliquityOfEcliptic(
749746 private static double calculateApparentSiderealTimeAtGreenwich (
750747 final JulianDate jd , final double deltaPsi , final double epsilonDegrees ) {
751748 final double nu0degrees =
752- limitDegreesTo360 (
749+ limitTo (
753750 280.46061837
754751 + 360.98564736629 * (jd .julianDate () - 2451545 )
755- + pow (jd .julianCentury (), 2 ) * (0.000387933 - jd .julianCentury () / 38710000 ));
752+ + pow (jd .julianCentury (), 2 ) * (0.000387933 - jd .julianCentury () / 38710000 ),
753+ 360 );
756754
757755 return nu0degrees + deltaPsi * cos (toRadians (epsilonDegrees ));
758756 }
@@ -790,10 +788,6 @@ private static double[] calculateNutationTerms(final double jce) {
790788 return x ;
791789 }
792790
793- private static double limitDegreesTo360 (final double degrees ) {
794- return limitTo (degrees , 360.0 );
795- }
796-
797791 private static double calculateLBRPolynomial (final double jme , final double [] terms ) {
798792 return polynomial (jme , terms ) / 1e8 ;
799793 }
0 commit comments