DiscreteRotationMath


object DiscreteRotationMath


Utility functions for working with discrete rotations values 0, 90, 180, 270.

Summary

Public functions

Int
fromSurfaceRotation(surfaceRotation: Int)

Get a DiscreteRotation from Surface rotation values.

Unit

Throws an IllegalArgumentException if the given degrees is not one of 0, 90, 180, 270.

Int
round(degrees: Float)

Round degrees to the nearest discrete rotation (0, 90, 180, 270).

Int
round(degrees: Int)

Round degrees to the nearest discrete rotation (0, 90, 180, 270).

Public functions

fromSurfaceRotation

Added in 1.7.0-alpha01
fun fromSurfaceRotation(surfaceRotation: Int): Int

Get a DiscreteRotation from Surface rotation values.

requireDiscreteRotation

Added in 1.7.0-alpha01
fun requireDiscreteRotation(degrees: Int): Unit

Throws an IllegalArgumentException if the given degrees is not one of 0, 90, 180, 270.

round

Added in 1.7.0-alpha01
fun round(degrees: Float): Int

Round degrees to the nearest discrete rotation (0, 90, 180, 270). Negative values are rounded to the nearest positive discrete rotation value.

Example(s):

  • 40.000f => 0°

  • 44.990f => 0°

  • 45.001f => 90°

  • -40.00f° => 0° (Equivalent to -40.000f + 360 => round(320) => 0)

  • -50.00f° => 270° (Equivalent to -50.000f + 360 => round(310) => 270)

round

Added in 1.7.0-alpha01
fun round(degrees: Int): Int

Round degrees to the nearest discrete rotation (0, 90, 180, 270). Negative values are rounded to the nearest positive discrete rotation value.

Example(s):

  • 40 => 0°

  • 50 => 90°

  • -40 => 0° (Equivalent to -40 + 360 => round(320) => 0)

  • -50 => 270° (Equivalent to -50 + 360 => round(310) => 270°)