Class BayazitDecomposer.SimplifyTools

java.lang.Object
net.dermetfan.gdx.math.BayazitDecomposer.SimplifyTools
Enclosing class:
BayazitDecomposer

public static class BayazitDecomposer.SimplifyTools extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    collinear(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, com.badlogic.gdx.math.Vector2 c, float tolerance)
     
    static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2>
    collinearSimplify(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
    Removes all collinear points on the polygon.
    static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2>
    collinearSimplify(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float collinearityTolerance)
    Removes all collinear points on the polygon.
    static Float
    cross(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b)
     
    static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2>
    douglasPeuckerSimplify(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float distanceTolerance)
    Ramer-Douglas-Peucker polygon simplification algorithm.
    static boolean
    floatInRange(float value, float min, float max)
     
    static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2>
    mergeIdenticalPoints(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
    Merges the identical points in the polygon.
    static void
    mergeParallelEdges(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float tolerance)
    From Eric Jordan's convex decomposition library Merges all parallel edges in the list of vertices
    static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2>
    reduceByArea(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float areaTolerance)
     
    static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2>
    reduceByDistance(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float distance)
    Reduces the polygon by distance.
    static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2>
    reduceByNth(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, int nth)
    Reduces the polygon by removing the Nth vertex in the vertices list.

    Methods inherited from class java.lang.Object

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

    • SimplifyTools

      public SimplifyTools()
  • Method Details

    • collinearSimplify

      public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> collinearSimplify(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float collinearityTolerance)
      Removes all collinear points on the polygon.
      Parameters:
      vertices - The polygon that needs simplification.
      collinearityTolerance - The collinearity tolerance.
      Returns:
      A simplified polygon.
    • collinear

      public static boolean collinear(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, com.badlogic.gdx.math.Vector2 c, float tolerance)
    • floatInRange

      public static boolean floatInRange(float value, float min, float max)
    • collinearSimplify

      public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> collinearSimplify(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      Removes all collinear points on the polygon. Has a default bias of 0
      Parameters:
      vertices - The polygon that needs simplification
      Returns:
      A simplified polygon.
    • douglasPeuckerSimplify

      public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> douglasPeuckerSimplify(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float distanceTolerance)
      Ramer-Douglas-Peucker polygon simplification algorithm. This is the general recursive version that does not use the speed-up technique by using the Melkman convex hull. If you pass in 0, it will remove all collinear points
      Parameters:
      vertices -
      distanceTolerance -
      Returns:
      The simplified polygon
    • reduceByArea

      public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> reduceByArea(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float areaTolerance)
    • cross

      public static Float cross(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b)
    • mergeParallelEdges

      public static void mergeParallelEdges(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float tolerance)
      From Eric Jordan's convex decomposition library Merges all parallel edges in the list of vertices
    • mergeIdenticalPoints

      public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> mergeIdenticalPoints(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices)
      Merges the identical points in the polygon.
    • reduceByDistance

      public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> reduceByDistance(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, float distance)
      Reduces the polygon by distance.
      Parameters:
      vertices -
      distance - The distance between points. Points closer than this will be 'joined'
    • reduceByNth

      public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> reduceByNth(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> vertices, int nth)
      Reduces the polygon by removing the Nth vertex in the vertices list.
      Parameters:
      vertices -
      nth - The Nth point to remove. Example: 5.