Class GeometryUtils

java.lang.Object
net.dermetfan.utils.math.GeometryUtils
net.dermetfan.gdx.math.GeometryUtils

public class GeometryUtils
extends GeometryUtils
Provides some useful methods for geometric calculations. Note that many methods return the same array instance so make a copy for subsequent calls.
  • Constructor Summary

    Constructors
    Constructor Description
    GeometryUtils()  
  • Method Summary

    Modifier and Type Method Description
    static com.badlogic.gdx.math.Vector2 abs​(com.badlogic.gdx.math.Vector2 vector)  
    static com.badlogic.gdx.math.Vector3 abs​(com.badlogic.gdx.math.Vector3 vector)  
    static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> add​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float x, float y)  
    static com.badlogic.gdx.utils.FloatArray add​(com.badlogic.gdx.utils.FloatArray vertices, float x, float y)  
    static com.badlogic.gdx.utils.FloatArray addX​(com.badlogic.gdx.utils.FloatArray vertices, float value)  
    static com.badlogic.gdx.utils.FloatArray addY​(com.badlogic.gdx.utils.FloatArray vertices, float value)  
    static boolean areVerticesClockwise​(com.badlogic.gdx.math.Polygon polygon)  
    static boolean areVerticesClockwise​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)  
    static boolean areVerticesClockwise​(com.badlogic.gdx.utils.FloatArray vertices)  
    static void arrangeConvexPolygon​(com.badlogic.gdx.utils.FloatArray vertices, boolean clockwise)  
    static boolean between​(com.badlogic.gdx.math.Vector2 point, com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b)  
    static boolean between​(com.badlogic.gdx.math.Vector2 point, com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, boolean inclusive)  
    static void clip​(float[] polygon, float[] clip, com.badlogic.gdx.utils.FloatArray clipped)  
    static void clip​(float[] polygon, int offset, int length, float[] clip, int clipOffset, int clipLength, com.badlogic.gdx.utils.FloatArray clipped)
    an implementation of the Sutherland-Hodgman algorithm
    static float[][] decompose​(float[] concave)  
    static float[][] decompose​(float[] concave, int offset, int length)  
    static float depth​(com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.utils.FloatArray div​(com.badlogic.gdx.utils.FloatArray vertices, float divisorX, float divisorY)  
    static com.badlogic.gdx.utils.FloatArray divX​(com.badlogic.gdx.utils.FloatArray vertices, float divisor)  
    static com.badlogic.gdx.utils.FloatArray divY​(com.badlogic.gdx.utils.FloatArray vertices, float divisor)  
    static com.badlogic.gdx.utils.FloatArray filterW​(com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.utils.FloatArray filterW​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.utils.FloatArray output)  
    static com.badlogic.gdx.utils.FloatArray filterX​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)  
    static com.badlogic.gdx.utils.FloatArray filterX​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, com.badlogic.gdx.utils.FloatArray output)  
    static com.badlogic.gdx.utils.FloatArray filterX​(com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.utils.FloatArray filterX​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.utils.FloatArray output)  
    static com.badlogic.gdx.utils.FloatArray filterX3D​(com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.utils.FloatArray filterX3D​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.utils.FloatArray output)  
    static com.badlogic.gdx.utils.FloatArray filterY​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)  
    static com.badlogic.gdx.utils.FloatArray filterY​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, com.badlogic.gdx.utils.FloatArray output)  
    static com.badlogic.gdx.utils.FloatArray filterY​(com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.utils.FloatArray filterY​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.utils.FloatArray output)  
    static com.badlogic.gdx.utils.FloatArray filterY3D​(com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.utils.FloatArray filterY3D​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.utils.FloatArray output)  
    static com.badlogic.gdx.utils.FloatArray filterZ​(com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.utils.FloatArray filterZ​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.utils.FloatArray output)  
    static float height​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)  
    static float height​(com.badlogic.gdx.utils.FloatArray vertices)  
    static int intersectSegmentConvexPolygon​(float x1, float y1, float x2, float y2, float[] polygon, int offset, int length, com.badlogic.gdx.math.Vector2 intersection1, com.badlogic.gdx.math.Vector2 intersection2)  
    static int intersectSegmentConvexPolygon​(float x1, float y1, float x2, float y2, float[] polygon, com.badlogic.gdx.math.Vector2 intersection1, com.badlogic.gdx.math.Vector2 intersection2)  
    static int intersectSegmentConvexPolygon​(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, com.badlogic.gdx.utils.FloatArray polygon, com.badlogic.gdx.math.Vector2 intersection1, com.badlogic.gdx.math.Vector2 intersection2)  
    static boolean intersectSegments​(float x1, float y1, float x2, float y2, float[] segments, int offset, int length, boolean polygon, com.badlogic.gdx.utils.FloatArray intersections)  
    static boolean intersectSegments​(float x1, float y1, float x2, float y2, com.badlogic.gdx.utils.FloatArray segments, boolean polygon, com.badlogic.gdx.utils.FloatArray intersections)  
    static boolean intersectSegments​(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, com.badlogic.gdx.utils.FloatArray segments, boolean polygon, com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> intersections)  
    static com.badlogic.gdx.utils.FloatArray invertAxes​(com.badlogic.gdx.utils.FloatArray vertices, boolean x, boolean y)  
    static boolean isConvex​(com.badlogic.gdx.math.Polygon polygon)  
    static boolean isConvex​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)  
    static boolean isConvex​(com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.math.Vector2 keepWithin​(float x, float y, float width, float height, float rectX, float rectY, float rectWidth, float rectHeight)  
    static void keepWithin​(com.badlogic.gdx.graphics.OrthographicCamera camera, float x, float y, float width, float height)
    Keeps the given OrthographicCamera in the given rectangle.
    static com.badlogic.gdx.math.Rectangle keepWithin​(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Rectangle other)  
    static com.badlogic.gdx.math.Vector2 keepWithin​(com.badlogic.gdx.math.Vector2 position, float width, float height, float x2, float y2, float width2, float height2)
    Keeps the first described rectangle in the second described rectangle.
    static float maxX​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)  
    static float maxX​(com.badlogic.gdx.utils.FloatArray vertices)  
    static float maxY​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)  
    static float maxY​(com.badlogic.gdx.utils.FloatArray vertices)  
    static float minX​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)  
    static float minX​(com.badlogic.gdx.utils.FloatArray vertices)  
    static float minY​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)  
    static float minY​(com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.utils.FloatArray mul​(com.badlogic.gdx.utils.FloatArray vertices, float factorX, float factorY)  
    static com.badlogic.gdx.utils.FloatArray mulX​(com.badlogic.gdx.utils.FloatArray vertices, float factor)  
    static com.badlogic.gdx.utils.FloatArray mulY​(com.badlogic.gdx.utils.FloatArray vertices, float factor)  
    static float polygonArea​(com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.math.Circle reset​(com.badlogic.gdx.math.Circle circle)  
    static com.badlogic.gdx.math.Ellipse reset​(com.badlogic.gdx.math.Ellipse ellipse)  
    static com.badlogic.gdx.math.Polygon reset​(com.badlogic.gdx.math.Polygon polygon)  
    static com.badlogic.gdx.math.Polyline reset​(com.badlogic.gdx.math.Polyline polyline)  
    static com.badlogic.gdx.math.Rectangle reset​(com.badlogic.gdx.math.Rectangle rectangle)  
    static <T extends com.badlogic.gdx.math.Shape2D>
    T
    reset​(T shape)
    dispatch method
    static com.badlogic.gdx.utils.FloatArray reverse​(com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.utils.FloatArray reverse3D​(com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.utils.FloatArray rotate​(float x, float y, float width, float height, float radians)  
    static com.badlogic.gdx.utils.FloatArray rotate​(float x, float y, float width, float height, float radians, com.badlogic.gdx.utils.FloatArray output)  
    static com.badlogic.gdx.utils.FloatArray rotate​(com.badlogic.gdx.math.Rectangle rectangle, float radians)  
    static com.badlogic.gdx.utils.FloatArray rotate​(com.badlogic.gdx.math.Rectangle rectangle, float radians, com.badlogic.gdx.utils.FloatArray output)  
    static com.badlogic.gdx.math.Vector2 rotate​(com.badlogic.gdx.math.Vector2 point, com.badlogic.gdx.math.Vector2 origin, float radians)
    rotates a point around center
    static void rotateLine​(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, float radians)
    rotates the line around its center (same as rotate(Vector2, Vector2, float) using the center between both points as origin)
    static com.badlogic.gdx.utils.FloatArray scale​(com.badlogic.gdx.utils.FloatArray vertices, float minX, float minY, float maxX, float maxY)  
    static com.badlogic.gdx.utils.FloatArray scale​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.math.Vector2 min, com.badlogic.gdx.math.Vector2 max)  
    static com.badlogic.gdx.math.Rectangle setToAABB​(com.badlogic.gdx.math.Rectangle aabb, float[] vertices)  
    static com.badlogic.gdx.math.Rectangle setToAABB​(com.badlogic.gdx.math.Rectangle aabb, float[] vertices, int offset, int length)  
    static com.badlogic.gdx.math.Rectangle setToAABB​(com.badlogic.gdx.math.Rectangle aabb, com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)  
    static com.badlogic.gdx.math.Rectangle setToAABB​(com.badlogic.gdx.math.Rectangle aabb, com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.math.Vector2 size​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)  
    static com.badlogic.gdx.math.Vector2 size​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, com.badlogic.gdx.math.Vector2 output)  
    static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> sub​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float x, float y)  
    static com.badlogic.gdx.utils.FloatArray sub​(com.badlogic.gdx.utils.FloatArray vertices, float x, float y)  
    static com.badlogic.gdx.utils.FloatArray subX​(com.badlogic.gdx.utils.FloatArray vertices, float value)  
    static com.badlogic.gdx.utils.FloatArray subY​(com.badlogic.gdx.utils.FloatArray vertices, float value)  
    static com.badlogic.gdx.utils.FloatArray toFloatArray​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vector2s)  
    static com.badlogic.gdx.utils.FloatArray toFloatArray​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vector2s, com.badlogic.gdx.utils.FloatArray output)  
    static com.badlogic.gdx.math.Polygon[] toPolygonArray​(float[][] polygons)  
    static com.badlogic.gdx.math.Polygon[] toPolygonArray​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, int vertexCount)  
    static com.badlogic.gdx.math.Polygon[] toPolygonArray​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, com.badlogic.gdx.utils.IntArray vertexCounts)  
    static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> toVector2Array​(com.badlogic.gdx.utils.FloatArray floats)  
    static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> toVector2Array​(com.badlogic.gdx.utils.FloatArray floats, com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> output)  
    static com.badlogic.gdx.utils.FloatArray toYDown​(com.badlogic.gdx.utils.FloatArray vertices)  
    static com.badlogic.gdx.utils.FloatArray toYUp​(com.badlogic.gdx.utils.FloatArray vertices)  
    static float[][] triangulate​(float[] polygon)  
    static float[][] triangulate​(float[] polygon, int offset, int length)  
    static float width​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)  
    static float width​(com.badlogic.gdx.utils.FloatArray vertices)  

    Methods inherited from class java.lang.Object

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

    • GeometryUtils

      public GeometryUtils()
  • Method Details

    • between

      public static boolean between​(com.badlogic.gdx.math.Vector2 point, com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, boolean inclusive)
      See Also:
      GeometryUtils.between(float, float, float, float, float, float, boolean)
    • between

      public static boolean between​(com.badlogic.gdx.math.Vector2 point, com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b)
      See Also:
      GeometryUtils.between(float, float, float, float, float, float)
    • abs

      public static com.badlogic.gdx.math.Vector2 abs​(com.badlogic.gdx.math.Vector2 vector)
      Parameters:
      vector - the Vector2 which components to set to their absolute value
      Returns:
      the given vector with all components set to its absolute value
      See Also:
      Math.abs(float)
    • abs

      public static com.badlogic.gdx.math.Vector3 abs​(com.badlogic.gdx.math.Vector3 vector)
      See Also:
      abs(Vector2)
    • add

      public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> add​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float x, float y)
      Parameters:
      vertices - the vertices to add the given values to
      x - the x value to add
      y - the y value to add
      Returns:
      the given vertices for chaining
    • sub

      public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> sub​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float x, float y)
      See Also:
      add(Array, float, float)
    • add

      public static com.badlogic.gdx.utils.FloatArray add​(com.badlogic.gdx.utils.FloatArray vertices, float x, float y)
      See Also:
      add(Array, float, float)
    • sub

      public static com.badlogic.gdx.utils.FloatArray sub​(com.badlogic.gdx.utils.FloatArray vertices, float x, float y)
      See Also:
      add(Array, float, float)
    • addX

      public static com.badlogic.gdx.utils.FloatArray addX​(com.badlogic.gdx.utils.FloatArray vertices, float value)
      See Also:
      add(FloatArray, float, float)
    • subX

      public static com.badlogic.gdx.utils.FloatArray subX​(com.badlogic.gdx.utils.FloatArray vertices, float value)
      See Also:
      sub(FloatArray, float, float)
    • addY

      public static com.badlogic.gdx.utils.FloatArray addY​(com.badlogic.gdx.utils.FloatArray vertices, float value)
      See Also:
      add(FloatArray, float, float)
    • subY

      public static com.badlogic.gdx.utils.FloatArray subY​(com.badlogic.gdx.utils.FloatArray vertices, float value)
      See Also:
      sub(FloatArray, float, float)
    • mul

      public static com.badlogic.gdx.utils.FloatArray mul​(com.badlogic.gdx.utils.FloatArray vertices, float factorX, float factorY)
      See Also:
      GeometryUtils.mul(float[], int, int, float, float)
    • mulX

      public static com.badlogic.gdx.utils.FloatArray mulX​(com.badlogic.gdx.utils.FloatArray vertices, float factor)
      See Also:
      GeometryUtils.mulX(float[], int, int, float)
    • mulY

      public static com.badlogic.gdx.utils.FloatArray mulY​(com.badlogic.gdx.utils.FloatArray vertices, float factor)
      See Also:
      GeometryUtils.mulY(float[], int, int, float)
    • div

      public static com.badlogic.gdx.utils.FloatArray div​(com.badlogic.gdx.utils.FloatArray vertices, float divisorX, float divisorY)
      See Also:
      GeometryUtils.div(float[], int, int, float, float)
    • divX

      public static com.badlogic.gdx.utils.FloatArray divX​(com.badlogic.gdx.utils.FloatArray vertices, float divisor)
      See Also:
      GeometryUtils.divX(float[], int, int, float)
    • divY

      public static com.badlogic.gdx.utils.FloatArray divY​(com.badlogic.gdx.utils.FloatArray vertices, float divisor)
      See Also:
      GeometryUtils.divY(float[], int, int, float)
    • size

      public static com.badlogic.gdx.math.Vector2 size​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, com.badlogic.gdx.math.Vector2 output)
      Returns:
      a Vector2 representing the size of a rectangle containing all given vertices
    • size

      public static com.badlogic.gdx.math.Vector2 size​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      See Also:
      size(Array, Vector2)
    • width

      public static float width​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      Returns:
      the amplitude from the min x vertice to the max x vertice
    • height

      public static float height​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      Returns:
      the amplitude from the min y vertice to the max y vertice
    • width

      public static float width​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      width(Array)
    • height

      public static float height​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      height(Array)
    • depth

      public static float depth​(com.badlogic.gdx.utils.FloatArray vertices)
      Returns:
      the amplitude of the min z vertice to the max z vertice
    • filterX

      public static com.badlogic.gdx.utils.FloatArray filterX​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, com.badlogic.gdx.utils.FloatArray output)
      Returns:
      the x values of the given vertices
    • filterX

      public static com.badlogic.gdx.utils.FloatArray filterX​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      See Also:
      filterX(Array, FloatArray)
    • filterX

      public static com.badlogic.gdx.utils.FloatArray filterX​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.utils.FloatArray output)
      Parameters:
      vertices - the vertices in [x, y, x, y, ...] order
      See Also:
      filterX(Array)
    • filterX

      public static com.badlogic.gdx.utils.FloatArray filterX​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      filterX(FloatArray, FloatArray)
    • filterX3D

      public static com.badlogic.gdx.utils.FloatArray filterX3D​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.utils.FloatArray output)
      Parameters:
      vertices - the vertices in [x, y, z, x, y, z, ...] order
      See Also:
      filterX(FloatArray, FloatArray)
    • filterX3D

      public static com.badlogic.gdx.utils.FloatArray filterX3D​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      filterX3D(FloatArray, FloatArray)
    • filterY

      public static com.badlogic.gdx.utils.FloatArray filterY​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, com.badlogic.gdx.utils.FloatArray output)
      Returns:
      the y values of the given vertices
    • filterY

      public static com.badlogic.gdx.utils.FloatArray filterY​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      See Also:
      filterY(Array, FloatArray)
    • filterY

      public static com.badlogic.gdx.utils.FloatArray filterY​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.utils.FloatArray output)
      See Also:
      filterY(Array, FloatArray), filterX(FloatArray, FloatArray)
    • filterY

      public static com.badlogic.gdx.utils.FloatArray filterY​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      filterY(FloatArray, FloatArray)
    • filterY3D

      public static com.badlogic.gdx.utils.FloatArray filterY3D​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.utils.FloatArray output)
      See Also:
      filterY(FloatArray, FloatArray), filterX3D(FloatArray, FloatArray)
    • filterY3D

      public static com.badlogic.gdx.utils.FloatArray filterY3D​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      filterY3D(FloatArray, FloatArray)
    • filterZ

      public static com.badlogic.gdx.utils.FloatArray filterZ​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.utils.FloatArray output)
      See Also:
      filterX(Array, FloatArray), filterX3D(FloatArray, FloatArray)
    • filterZ

      public static com.badlogic.gdx.utils.FloatArray filterZ​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      filterZ(FloatArray, FloatArray)
    • filterW

      public static com.badlogic.gdx.utils.FloatArray filterW​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.utils.FloatArray output)
      See Also:
      filterX3D(FloatArray)
    • filterW

      public static com.badlogic.gdx.utils.FloatArray filterW​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      filterW(FloatArray, FloatArray)
    • minX

      public static float minX​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      Returns:
      the min x value of the given vertices
    • minY

      public static float minY​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      Returns:
      the min y value of the given vertices
    • maxX

      public static float maxX​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      Returns:
      the max x value of the given vertices
    • maxY

      public static float maxY​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      Returns:
      the max y value of the given vertices
    • minX

      public static float minX​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      minX(Array)
    • minY

      public static float minY​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      minY(Array)
    • maxX

      public static float maxX​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      maxX(Array)
    • maxY

      public static float maxY​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      maxY(Array)
    • scale

      public static com.badlogic.gdx.utils.FloatArray scale​(com.badlogic.gdx.utils.FloatArray vertices, float minX, float minY, float maxX, float maxY)
      See Also:
      GeometryUtils.scale(float[], int, int, float, float, float, float)
    • scale

      public static com.badlogic.gdx.utils.FloatArray scale​(com.badlogic.gdx.utils.FloatArray vertices, com.badlogic.gdx.math.Vector2 min, com.badlogic.gdx.math.Vector2 max)
      See Also:
      scale(FloatArray, float, float, float, float)
    • reverse

      public static com.badlogic.gdx.utils.FloatArray reverse​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      GeometryUtils.reverse(float[])
    • reverse3D

      public static com.badlogic.gdx.utils.FloatArray reverse3D​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      GeometryUtils.reverse3D(float[])
    • rotate

      public static com.badlogic.gdx.math.Vector2 rotate​(com.badlogic.gdx.math.Vector2 point, com.badlogic.gdx.math.Vector2 origin, float radians)
      rotates a point around center
      Parameters:
      point - the point to rotate
      origin - the point around which to rotate point
      radians - the rotation
      Returns:
      the given point rotated around center by radians
    • rotateLine

      public static void rotateLine​(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, float radians)
      rotates the line around its center (same as rotate(Vector2, Vector2, float) using the center between both points as origin)
      Parameters:
      a - a point on the line
      b - another point on the line
      radians - the rotation
    • rotate

      public static com.badlogic.gdx.utils.FloatArray rotate​(float x, float y, float width, float height, float radians, com.badlogic.gdx.utils.FloatArray output)
      See Also:
      GeometryUtils.rotate(float, float, float, float, float, float[], int)
    • rotate

      public static com.badlogic.gdx.utils.FloatArray rotate​(float x, float y, float width, float height, float radians)
      See Also:
      rotate(float, float, float, float, float, FloatArray)
    • rotate

      public static com.badlogic.gdx.utils.FloatArray rotate​(com.badlogic.gdx.math.Rectangle rectangle, float radians, com.badlogic.gdx.utils.FloatArray output)
      See Also:
      rotate(float, float, float, float, float, FloatArray)
    • rotate

      public static com.badlogic.gdx.utils.FloatArray rotate​(com.badlogic.gdx.math.Rectangle rectangle, float radians)
      See Also:
      rotate(Rectangle, float, FloatArray)
    • toFloatArray

      public static com.badlogic.gdx.utils.FloatArray toFloatArray​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vector2s, com.badlogic.gdx.utils.FloatArray output)
      Parameters:
      vector2s - the Vector2s to convert to a FloatArray
      Returns:
      the FloatArray converted from the given Vector2s
    • toFloatArray

      public static com.badlogic.gdx.utils.FloatArray toFloatArray​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vector2s)
      See Also:
      toFloatArray(Array, FloatArray)
    • toVector2Array

      public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> toVector2Array​(com.badlogic.gdx.utils.FloatArray floats, com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> output)
      Parameters:
      floats - the FloatArray to convert to an Array<Vector2>
      Returns:
      the Array<Vector2> converted from the given FloatArray
    • toVector2Array

      public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> toVector2Array​(com.badlogic.gdx.utils.FloatArray floats)
      See Also:
      toVector2Array(FloatArray, Array)
    • toPolygonArray

      public static com.badlogic.gdx.math.Polygon[] toPolygonArray​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, int vertexCount)
      Parameters:
      vertexCount - the number of vertices for each Polygon
      See Also:
      toPolygonArray(Array, IntArray)
    • toPolygonArray

      public static com.badlogic.gdx.math.Polygon[] toPolygonArray​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, com.badlogic.gdx.utils.IntArray vertexCounts)
      Parameters:
      vertices - the vertices which should be split into a Polygon array
      vertexCounts - the number of vertices of each Polygon
      Returns:
      the Polygon array extracted from the vertices
    • toPolygonArray

      public static com.badlogic.gdx.math.Polygon[] toPolygonArray​(float[][] polygons)
      Parameters:
      polygons - the polygons' vertices
      Returns:
      an array of Polygons created from the given polygons' vertices
    • areVerticesClockwise

      public static boolean areVerticesClockwise​(com.badlogic.gdx.math.Polygon polygon)
      Parameters:
      polygon - the polygon, assumed to be simple
      Returns:
      if the vertices are in clockwise order
    • areVerticesClockwise

      public static boolean areVerticesClockwise​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      areVerticesClockwise(Polygon)
    • areVerticesClockwise

      public static boolean areVerticesClockwise​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      See Also:
      areVerticesClockwise(FloatArray)
    • polygonArea

      public static float polygonArea​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      GeometryUtils.polygonArea(float[], int, int)
    • arrangeConvexPolygon

      public static void arrangeConvexPolygon​(com.badlogic.gdx.utils.FloatArray vertices, boolean clockwise)
      See Also:
      GeometryUtils.arrangeConvexPolygon(float[], int, int, boolean)
    • invertAxes

      public static com.badlogic.gdx.utils.FloatArray invertAxes​(com.badlogic.gdx.utils.FloatArray vertices, boolean x, boolean y)
      See Also:
      GeometryUtils.invertAxes(float[], int, int, boolean, boolean)
    • toYDown

      public static com.badlogic.gdx.utils.FloatArray toYDown​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      GeometryUtils.toYDown(float[])
    • toYUp

      public static com.badlogic.gdx.utils.FloatArray toYUp​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      GeometryUtils.toYUp(float[])
    • setToAABB

      public static com.badlogic.gdx.math.Rectangle setToAABB​(com.badlogic.gdx.math.Rectangle aabb, float[] vertices, int offset, int length)
      Parameters:
      aabb - the rectangle to set as AABB of the given vertices
      vertices - the vertices
      Returns:
      the given Rectangle for chaining
    • setToAABB

      public static com.badlogic.gdx.math.Rectangle setToAABB​(com.badlogic.gdx.math.Rectangle aabb, float[] vertices)
      See Also:
      setToAABB(Rectangle, float[], int, int)
    • setToAABB

      public static com.badlogic.gdx.math.Rectangle setToAABB​(com.badlogic.gdx.math.Rectangle aabb, com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      setToAABB(Rectangle, float[], int, int)
    • setToAABB

      public static com.badlogic.gdx.math.Rectangle setToAABB​(com.badlogic.gdx.math.Rectangle aabb, com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      See Also:
      setToAABB(Rectangle, FloatArray)
    • isConvex

      public static boolean isConvex​(com.badlogic.gdx.utils.FloatArray vertices)
      See Also:
      GeometryUtils.isConvex(float[], int, int)
    • isConvex

      public static boolean isConvex​(com.badlogic.gdx.math.Polygon polygon)
      See Also:
      GeometryUtils.isConvex(float[])
    • isConvex

      public static boolean isConvex​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      See Also:
      isConvex(FloatArray)
    • triangulate

      public static float[][] triangulate​(float[] polygon)
      See Also:
      triangulate(float[], int, int)
    • triangulate

      public static float[][] triangulate​(float[] polygon, int offset, int length)
      Parameters:
      polygon - the polygon to triangulate
      Returns:
      the triangles created from the polygon
      See Also:
      EarClippingTriangulator
    • decompose

      public static float[][] decompose​(float[] concave)
      See Also:
      decompose(float[], int, int)
    • decompose

      public static float[][] decompose​(float[] concave, int offset, int length)
      Parameters:
      concave - the concave polygon to to decompose
      Returns:
      an array of convex polygons representing the given concave polygon
      See Also:
      BayazitDecomposer.convexPartition(Array)
    • keepWithin

      public static com.badlogic.gdx.math.Vector2 keepWithin​(com.badlogic.gdx.math.Vector2 position, float width, float height, float x2, float y2, float width2, float height2)
      Keeps the first described rectangle in the second described rectangle. If the second rectangle is smaller than the first one, the first will be centered on the second one.
      Parameters:
      position - the position of the first rectangle
      width - the width of the first rectangle
      height - the height of the first rectangle
      x2 - the x of the second rectangle
      y2 - the y of the second rectangle
      width2 - the width of the second rectangle
      height2 - the height of the second rectangle
      Returns:
      the position of the first rectangle
    • keepWithin

      public static com.badlogic.gdx.math.Vector2 keepWithin​(float x, float y, float width, float height, float rectX, float rectY, float rectWidth, float rectHeight)
      See Also:
      keepWithin(Vector2, float, float, float, float, float, float)
    • keepWithin

      public static com.badlogic.gdx.math.Rectangle keepWithin​(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Rectangle other)
      See Also:
      keepWithin(float, float, float, float, float, float, float, float)
    • keepWithin

      public static void keepWithin​(com.badlogic.gdx.graphics.OrthographicCamera camera, float x, float y, float width, float height)
      Keeps the given OrthographicCamera in the given rectangle. If the rectangle is smaller than the camera viewport times the camera zoom, the camera will be centered on the rectangle.
      Note that the camera will not be updated.
      Parameters:
      camera - the camera to keep in the rectangle
      See Also:
      keepWithin(float, float, float, float, float, float, float, float)
    • intersectSegmentConvexPolygon

      public static int intersectSegmentConvexPolygon​(float x1, float y1, float x2, float y2, float[] polygon, com.badlogic.gdx.math.Vector2 intersection1, com.badlogic.gdx.math.Vector2 intersection2)
      See Also:
      intersectSegmentConvexPolygon(float, float, float, float, float[], int, int, Vector2, Vector2)
    • intersectSegmentConvexPolygon

      public static int intersectSegmentConvexPolygon​(float x1, float y1, float x2, float y2, float[] polygon, int offset, int length, com.badlogic.gdx.math.Vector2 intersection1, com.badlogic.gdx.math.Vector2 intersection2)
      Parameters:
      x1 - the x coordinate of the first point of the segment to intersect with the polygon
      y1 - the y coordinate of the first point of the segment to intersect with the polygon
      x2 - the x coordinate of the second point of the segment to intersect with the polygon
      y2 - the y coordinate of the second point of the segment to intersect with the polygon
      polygon - the convex polygon
      intersection1 - The first intersection point. May be null.
      intersection2 - The second intersection point. May be null.
      Returns:
      The number of intersection points. May return 0, 1, 2 or -1 for an infinite number of intersections (if the segment lies on a side of the polygon).
      See Also:
      intersectSegments(float, float, float, float, float[], int, int, boolean, FloatArray)
    • intersectSegmentConvexPolygon

      public static int intersectSegmentConvexPolygon​(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, com.badlogic.gdx.utils.FloatArray polygon, com.badlogic.gdx.math.Vector2 intersection1, com.badlogic.gdx.math.Vector2 intersection2)
      See Also:
      intersectSegmentConvexPolygon(float, float, float, float, float[], int, int, Vector2, Vector2)
    • intersectSegments

      public static boolean intersectSegments​(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, com.badlogic.gdx.utils.FloatArray segments, boolean polygon, com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> intersections)
      See Also:
      intersectSegments(float, float, float, float, FloatArray, boolean, FloatArray)
    • intersectSegments

      public static boolean intersectSegments​(float x1, float y1, float x2, float y2, com.badlogic.gdx.utils.FloatArray segments, boolean polygon, com.badlogic.gdx.utils.FloatArray intersections)
      See Also:
      intersectSegments(float, float, float, float, float[], int, int, boolean, FloatArray)
    • intersectSegments

      public static boolean intersectSegments​(float x1, float y1, float x2, float y2, float[] segments, int offset, int length, boolean polygon, com.badlogic.gdx.utils.FloatArray intersections)
      Parameters:
      x1 - the x coordinate of the first point of the segment
      y1 - the y coordinate of the first point of the segment
      x2 - the x coordinate of the second point of the segment
      y2 - the y coordinate of the second point of the segment
      segments - the segments
      polygon - if the segments represent a closed polygon
      intersections - the array to store the intersections in
      Returns:
      whether the given segment intersects with any of the given segments
    • clip

      public static void clip​(float[] polygon, float[] clip, com.badlogic.gdx.utils.FloatArray clipped)
      See Also:
      clip(float[], float[], FloatArray)
    • clip

      public static void clip​(float[] polygon, int offset, int length, float[] clip, int clipOffset, int clipLength, com.badlogic.gdx.utils.FloatArray clipped)
      an implementation of the Sutherland-Hodgman algorithm
      Parameters:
      polygon - the polygon to clip
      clip - the clipping polygon
      clipped - the FloatArray to store the resulting clipped polygon in
    • reset

      public static <T extends com.badlogic.gdx.math.Shape2D> T reset​(T shape)
      dispatch method
      Parameters:
      shape - the shape to reset
      Returns:
      the given shape for chaining
    • reset

      public static com.badlogic.gdx.math.Polygon reset​(com.badlogic.gdx.math.Polygon polygon)
      Parameters:
      polygon - the Polygon to reset
      Returns:
      the given Polygon for chaining
    • reset

      public static com.badlogic.gdx.math.Polyline reset​(com.badlogic.gdx.math.Polyline polyline)
      Parameters:
      polyline - the polyline to reset
      Returns:
      the given polyline for chaining
    • reset

      public static com.badlogic.gdx.math.Rectangle reset​(com.badlogic.gdx.math.Rectangle rectangle)
      Parameters:
      rectangle - the rectangle to reset
      Returns:
      the given rectangle for chaining
    • reset

      public static com.badlogic.gdx.math.Circle reset​(com.badlogic.gdx.math.Circle circle)
      Parameters:
      circle - the circle to reset
      Returns:
      the given circle for chaining
    • reset

      public static com.badlogic.gdx.math.Ellipse reset​(com.badlogic.gdx.math.Ellipse ellipse)
      Parameters:
      ellipse - the ellipse to reset
      Returns:
      the given ellipse for chaining