Class Utilities


  • public final class Utilities
    extends java.lang.Object
    Helper functions
    • Constructor Summary

      Constructors 
      Constructor Description
      Utilities()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double angleBetween​(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b)  
      static com.badlogic.gdx.math.Vector2 angleToVector​(com.badlogic.gdx.math.Vector2 out, float angle)  
      static boolean checkProximity​(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, float radius)
      checks the proximity of point a to point b
      static <T> boolean contains​(java.util.ArrayList<T> array, T a)
      does array contain a
      static int distanceToTiles​(float dist)  
      static com.badlogic.gdx.math.Vector2 distanceToTiles​(com.badlogic.gdx.math.Vector2 dist)  
      static com.badlogic.gdx.math.Vector2 floor​(com.badlogic.gdx.math.Vector2 a)
      floors the vector
      static <T> T randomChoice​(java.util.ArrayList<T> list)
      Chooses a random element
      static com.badlogic.gdx.math.Vector2 randomPos​(float min, float max)
      Random Vec2 in range
      static com.badlogic.gdx.math.Vector2 round​(com.badlogic.gdx.math.Vector2 x)  
      static float scale​(float min0, float max0, float min1, float max1)  
      static float scale​(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b)  
      static float tilesToDistance​(float tiles)  
      static com.badlogic.gdx.math.Vector2 tilesToDistance​(com.badlogic.gdx.math.Vector2 tiles)  
      static float vectorToAngle​(com.badlogic.gdx.math.Vector2 v)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Utilities

        public Utilities()
    • Method Detail

      • vectorToAngle

        public static float vectorToAngle​(com.badlogic.gdx.math.Vector2 v)
      • angleToVector

        public static com.badlogic.gdx.math.Vector2 angleToVector​(com.badlogic.gdx.math.Vector2 out,
                                                                  float angle)
      • tilesToDistance

        public static float tilesToDistance​(float tiles)
      • tilesToDistance

        public static com.badlogic.gdx.math.Vector2 tilesToDistance​(com.badlogic.gdx.math.Vector2 tiles)
      • distanceToTiles

        public static int distanceToTiles​(float dist)
      • distanceToTiles

        public static com.badlogic.gdx.math.Vector2 distanceToTiles​(com.badlogic.gdx.math.Vector2 dist)
      • checkProximity

        public static boolean checkProximity​(com.badlogic.gdx.math.Vector2 a,
                                             com.badlogic.gdx.math.Vector2 b,
                                             float radius)
        checks the proximity of point a to point b
        Parameters:
        a - first point
        b - second point
        radius - min dist to be considered close
        Returns:
        |dist(a, b)| < radius
      • angleBetween

        public static double angleBetween​(com.badlogic.gdx.math.Vector2 a,
                                          com.badlogic.gdx.math.Vector2 b)
      • scale

        public static float scale​(float min0,
                                  float max0,
                                  float min1,
                                  float max1)
      • scale

        public static float scale​(com.badlogic.gdx.math.Vector2 a,
                                  com.badlogic.gdx.math.Vector2 b)
      • round

        public static com.badlogic.gdx.math.Vector2 round​(com.badlogic.gdx.math.Vector2 x)
        Parameters:
        x - the vector to round
        Returns:
        x modified for chaining
      • randomPos

        public static com.badlogic.gdx.math.Vector2 randomPos​(float min,
                                                              float max)
        Random Vec2 in range
        Parameters:
        min - inclusive
        max - exclusive
        Returns:
        rand Vector2
      • randomChoice

        public static <T> T randomChoice​(java.util.ArrayList<T> list)
        Chooses a random element
        Type Parameters:
        T - type of element to return
        Parameters:
        list - source
        Returns:
        the random element
      • floor

        public static com.badlogic.gdx.math.Vector2 floor​(com.badlogic.gdx.math.Vector2 a)
        floors the vector
        Parameters:
        a - given vector
        Returns:
        new vector floored
      • contains

        public static <T> boolean contains​(java.util.ArrayList<T> array,
                                           T a)
        does array contain a
        Type Parameters:
        T - type of element looking for
        Parameters:
        array - source
        a - desired
        Returns:
        true if contained otherwise false