DiscreteRotationMath


public static class DiscreteRotationMath


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

Summary

Public fields

static @NonNull DiscreteRotationMath

Public methods

static final int
fromSurfaceRotation(int surfaceRotation)

Get a DiscreteRotation from Surface rotation values.

static final void

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

static final int
round(float degrees)

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

static final int
round(int degrees)

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

Public fields

INSTANCE

Added in 1.7.0-alpha01
public static @NonNull DiscreteRotationMath INSTANCE

Public methods

fromSurfaceRotation

Added in 1.7.0-alpha01
public static final int fromSurfaceRotation(int surfaceRotation)

Get a DiscreteRotation from Surface rotation values.

requireDiscreteRotation

Added in 1.7.0-alpha01
public static final void requireDiscreteRotation(int degrees)

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

round

Added in 1.7.0-alpha01
public static final int round(float degrees)

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
public static final int round(int degrees)

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°)