-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
7 changed files
with
160 additions
and
149 deletions.
There are no files selected for viewing
68 changes: 0 additions & 68 deletions
68
plugin/src/main/kotlin/io/github/addoncommunity/galactifun/units/Angle.kt
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
plugin/src/main/kotlin/io/github/addoncommunity/galactifun/units/Distance.kt
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
plugin/src/main/kotlin/io/github/addoncommunity/galactifun/units/Mass.kt
This file was deleted.
Oops, something went wrong.
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
41 changes: 41 additions & 0 deletions
41
plugin/src/main/kotlin/io/github/addoncommunity/galactifun/units/UnitsOfMeasure.kt
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,41 @@ | ||
@file:Suppress("unused") | ||
|
||
package io.github.addoncommunity.galactifun.units | ||
|
||
import io.github.addoncommunity.galactifun.Constants | ||
import io.github.addoncommunity.galactifun.units.Angle.Companion.radians | ||
import io.github.addoncommunity.galactifun.units.Distance.Companion.meters | ||
import io.github.addoncommunity.galactifun.units.Velocity.Companion.metersPerSecond | ||
import io.github.seggan.uom.AlternateUnit | ||
import io.github.seggan.uom.Measure | ||
import kotlin.math.PI | ||
import kotlin.time.Duration | ||
|
||
@Measure(base = "meters") | ||
@AlternateUnit(name = "lightYears", ratio = Constants.KM_PER_LY * 1000) | ||
@AlternateUnit(name = "kilometers", ratio = 1000.0) | ||
@AlternateUnit(name = "au", ratio = Constants.KM_PER_AU * 1000) | ||
private class ADistance | ||
|
||
@Measure(base = "kilograms") | ||
@AlternateUnit(name = "pounds", ratio = 2.20462) | ||
private class AMass | ||
|
||
@Measure(base = "metersPerSecond") | ||
private class AVelocity | ||
operator fun Distance.div(time: Duration): Velocity = (meters / time.doubleSeconds).metersPerSecond | ||
operator fun Velocity.times(time: Duration): Distance = (metersPerSecond * time.doubleSeconds).meters | ||
|
||
@Measure(base = "radians") | ||
@AlternateUnit(name = "degrees", ratio = 180.0 / Math.PI) | ||
private class AAngle | ||
|
||
val Angle.standardForm: Angle | ||
get() = ((radians % (2 * PI) + 2 * PI) % (2 * PI)).radians | ||
|
||
fun sin(angle: Angle): Double = kotlin.math.sin(angle.radians) | ||
fun cos(angle: Angle): Double = kotlin.math.cos(angle.radians) | ||
fun tan(angle: Angle): Double = kotlin.math.tan(angle.radians) | ||
fun sinh(angle: Angle): Double = kotlin.math.sinh(angle.radians) | ||
fun cosh(angle: Angle): Double = kotlin.math.cosh(angle.radians) | ||
fun tanh(angle: Angle): Double = kotlin.math.tanh(angle.radians) |
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