-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
632d059
commit 1dcdb77
Showing
5 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
True solar time = 11.6286 hours (11:37:42.979) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import io.github.cosinekitty.astronomy.* | ||
import kotlin.math.roundToInt | ||
|
||
/** | ||
* Calculate true solar time for a given observer and UTC time. | ||
* | ||
* @param observer | ||
* The geographic location for which to calculate apparent celestial body positions. | ||
* | ||
* @param time | ||
* The date and time for which to calculate positions. | ||
*/ | ||
internal fun `Solar true time`(observer: Observer, time: Time): Int { | ||
val ha = hourAngle(Body.Sun, time, observer) | ||
val solarTimeHours = (ha + 12.0) % 24.0 | ||
var milli = (solarTimeHours * 3.6e+6).roundToInt() | ||
var second = milli / 1000 | ||
milli %= 1000 | ||
var minute = second / 60 | ||
second %= 60 | ||
var hour = minute / 60 | ||
minute %= 60 | ||
hour %= 24 | ||
|
||
println("True solar time = %7.4f hours (%02d:%02d:%02d.%03d)".format( | ||
solarTimeHours, hour, minute, second, milli)) | ||
|
||
return 0 | ||
} |