org.jbox2d.collision
Class Distance

java.lang.Object
  extended by org.jbox2d.collision.Distance

public class Distance
extends Object

Implements the GJK algorithm for computing distance between shapes.


Field Summary
static int g_GJK_Iterations
           
 
Method Summary
static float distance(Vec2 x1, Vec2 x2, Shape shape1, XForm xf1, Shape shape2, XForm xf2)
          Find the closest distance between shapes shape1 and shape2, and load the closest points into x1 and x2.
static float DistanceCC(Vec2 x1, Vec2 x2, CircleShape circle1, XForm xf1, CircleShape circle2, XForm xf2)
          distance between two circle shapes
static float DistanceCirclePoint(Vec2 x1, Vec2 x2, CircleShape circle1, XForm xf1, PointShape pt2, XForm xf2)
          Distance between a circle and a point
static float DistanceEdgeCircle(Vec2 x1, Vec2 x2, EdgeShape edge, XForm xf1, CircleShape circle, XForm xf2)
          Distance bewteen an edge and a circle
static float DistanceGeneric(Vec2 x1, Vec2 x2, SupportsGenericDistance shape1, XForm xf1, SupportsGenericDistance shape2, XForm xf2)
          Distance between any two objects that implement SupportsGenericDistance.
static float DistancePC(Vec2 x1, Vec2 x2, PolygonShape polygon, XForm xf1, CircleShape circle, XForm xf2)
          Distance between a polygon and a circle
static float DistancePolygonPoint(Vec2 x1, Vec2 x2, PolygonShape polygon, XForm xf1, PointShape pt, XForm xf2)
          Distance between a polygon and a point
static boolean InPoints(Vec2 w, Vec2[] points, int pointCount)
           
protected static int ProcessThree(Vec2 x1, Vec2 x2, Vec2[] p1s, Vec2[] p2s, Vec2[] points)
           
protected static int ProcessTwo(Vec2 x1, Vec2 x2, Vec2[] p1s, Vec2[] p2s, Vec2[] points)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

g_GJK_Iterations

public static int g_GJK_Iterations
Method Detail

ProcessTwo

protected static final int ProcessTwo(Vec2 x1,
                                      Vec2 x2,
                                      Vec2[] p1s,
                                      Vec2[] p2s,
                                      Vec2[] points)

ProcessThree

protected static final int ProcessThree(Vec2 x1,
                                        Vec2 x2,
                                        Vec2[] p1s,
                                        Vec2[] p2s,
                                        Vec2[] points)

InPoints

public static final boolean InPoints(Vec2 w,
                                     Vec2[] points,
                                     int pointCount)

DistanceGeneric

public static final float DistanceGeneric(Vec2 x1,
                                          Vec2 x2,
                                          SupportsGenericDistance shape1,
                                          XForm xf1,
                                          SupportsGenericDistance shape2,
                                          XForm xf2)
Distance between any two objects that implement SupportsGenericDistance. Note that x1 and x2 are passed so that they may store results - they must be instantiated before being passed, and the contents will be lost.

Parameters:
x1 - Set to closest point on shape1 (result parameter)
x2 - Set to closest point on shape2 (result parameter)
shape1 - Shape to test
xf1 - Transform of shape1
shape2 - Shape to test
xf2 - Transform of shape2
Returns:
the distance

DistanceCC

public static final float DistanceCC(Vec2 x1,
                                     Vec2 x2,
                                     CircleShape circle1,
                                     XForm xf1,
                                     CircleShape circle2,
                                     XForm xf2)
distance between two circle shapes

Parameters:
x1 - Closest point on shape1 is put here (result parameter)
x2 - Closest point on shape2 is put here (result parameter)
circle1 -
xf1 - Transform of first shape
circle2 -
xf2 - Transform of second shape
Returns:
the distance

DistanceEdgeCircle

public static final float DistanceEdgeCircle(Vec2 x1,
                                             Vec2 x2,
                                             EdgeShape edge,
                                             XForm xf1,
                                             CircleShape circle,
                                             XForm xf2)
Distance bewteen an edge and a circle

Parameters:
x1 - Closest point on shape1 is put here (result parameter)
x2 - Closest point on shape2 is put here (result parameter)
edge -
xf1 - xform of edge
circle -
xf2 - xform of circle
Returns:
the distance

DistancePC

public static final float DistancePC(Vec2 x1,
                                     Vec2 x2,
                                     PolygonShape polygon,
                                     XForm xf1,
                                     CircleShape circle,
                                     XForm xf2)
Distance between a polygon and a circle

Parameters:
x1 - Closest point on shape1 is put here (result parameter)
x2 - Closest point on shape2 is put here (result parameter)
polygon -
xf1 - xform of polygon
circle -
xf2 - xform of circle
Returns:
the distance

DistancePolygonPoint

public static final float DistancePolygonPoint(Vec2 x1,
                                               Vec2 x2,
                                               PolygonShape polygon,
                                               XForm xf1,
                                               PointShape pt,
                                               XForm xf2)
Distance between a polygon and a point

Parameters:
x1 - Closest point on shape1 is put here (result parameter)
x2 - Closest point on shape2 is put here (result parameter)
polygon -
xf1 - xform of polygon
pt -
xf2 - xform of point
Returns:
the distance

DistanceCirclePoint

public static final float DistanceCirclePoint(Vec2 x1,
                                              Vec2 x2,
                                              CircleShape circle1,
                                              XForm xf1,
                                              PointShape pt2,
                                              XForm xf2)
Distance between a circle and a point

Parameters:
x1 - Closest point on shape1 is put here (result parameter)
x2 - Closest point on shape2 is put here (result parameter)
circle1 -
xf1 - xform of circle
pt2 -
xf2 - xform of point
Returns:
the distance

distance

public static final float distance(Vec2 x1,
                                   Vec2 x2,
                                   Shape shape1,
                                   XForm xf1,
                                   Shape shape2,
                                   XForm xf2)
Find the closest distance between shapes shape1 and shape2, and load the closest points into x1 and x2. Note that x1 and x2 are passed so that they may store results - they must be instantiated before being passed, and the contents will be lost.

Parameters:
x1 - Closest point on shape1 is put here (result parameter)
x2 - Closest point on shape2 is put here (result parameter)
shape1 - First shape to test
xf1 - Transform of first shape
shape2 - Second shape to test
xf2 - Transform of second shape
Returns:
the distance