Anonymous user
Angle difference between two bearings: Difference between revisions
Angle difference between two bearings (view source)
Revision as of 20:29, 27 August 2017
, 6 years ago→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
|||
Line 535:
class Angle(d: Double) {
val value
▲ d in -180.0 .. 180.0 -> d
▲ d > 180.0 -> (d - 180.0) % 360.0 - 180.0
▲ else -> (d + 180.0) % 360.0 + 180.0
}
operator fun minus(other: Angle) = Angle(this.value - other.value)
}
fun main(args: Array<String>) {
20.0 to 45.0,
-45.0 to 45.0,
Line 564 ⟶ 560:
)
println(" b1 b2 diff")
for (ap in anglePairs) {
val diff = Angle(ap.second) - Angle(ap.first)
|