no day-night cycle on titlescreen demo

This commit is contained in:
minjaesong
2023-07-10 20:44:35 +09:00
parent 6bc3d0e6ad
commit ec24dc9870
4 changed files with 22 additions and 7 deletions

View File

@@ -121,6 +121,17 @@ class WorldTime(initTime: Long = 0L) {
inline val moonPhase: Double
get() = (TIME_T.plus(1700000L) % LUNAR_CYCLE).toDouble() / LUNAR_CYCLE
fun getSolarElevationAt(ordinalDay: Int, second: Int): Double {
val TIME_T = DAY_LENGTH * ordinalDay + second
val x = (TIME_T % YEAR_SECONDS).toDouble() / DAY_LENGTH + 15 // decimal days. One full day = 1.0
val d = -23.44 * cos(TWO_PI * x / YEAR_DAYS)
// 51.56 and 23.44 will make yearly min/max elevation to be 75deg
// -0.2504264: a number that makes y=min when x=0 (x=0 is midnight)
return 51.56 * sin(TWO_PI * (x - 0.2504264)) + d
}
val solarElevationDeg: Double
get() {
val x = (TIME_T % YEAR_SECONDS).toDouble() / DAY_LENGTH + 15 // decimal days. One full day = 1.0