Fix Angle inversion
This commit is contained in:
parent
8429577fd8
commit
8e143eb81c
@ -85,8 +85,8 @@ public val Number.degrees: Degrees get() = Degrees(toDouble())
|
||||
* Normalized angle to (0, 2PI) for radians or (0, 360) for degrees.
|
||||
*/
|
||||
public fun Angle.normalized(): Angle = when (this) {
|
||||
is Degrees -> (value + 180.0).rem(360.0).degrees
|
||||
is Radians -> (value + PI).rem(PI * 2).radians
|
||||
is Degrees -> value.mod(360.0).degrees
|
||||
is Radians -> value.mod(PI * 2).radians
|
||||
}
|
||||
|
||||
public fun abs(angle: Angle): Angle = if (angle < Angle.zero) -angle else angle
|
@ -0,0 +1,12 @@
|
||||
package center.sciprog.maps.coordinates
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class AngleTest {
|
||||
@Test
|
||||
fun normalization(){
|
||||
assertEquals(30.degrees, 390.degrees.normalized())
|
||||
assertEquals(30.degrees, (-330).degrees.normalized())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user