public class MathUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static double |
distanceBetween(int left1,
int top1,
int right1,
int bottom1,
int left2,
int top2,
int right2,
int bottom2)
Returns the distance between two boxes.
|
static int |
estimateDistanceBetween(int x1,
int y1,
int x2,
int y2)
Returns the distance as BW would between two points.
|
static int |
estimateDistanceBetween(int left1,
int top1,
int right1,
int bottom1,
int left2,
int top2,
int right2,
int bottom2)
Returns the distance as BW would between two boxes.
|
public static double distanceBetween(int left1, int top1, int right1, int bottom1, int left2, int top2, int right2, int bottom2)
left1
- the left of the first box.top1
- the top of the first box.right1
- the right of the first box.bottom1
- the bottom of the first box.left2
- the left of the second box.top2
- the top of the second box.right2
- the right of the second box.bottom2
- the bottom of the second box.public static int estimateDistanceBetween(int x1, int y1, int x2, int y2)
x1
- the x value of the first point.y1
- the y value of the first point.x2
- the x value of the second point.y2
- the y value of the second point.public static int estimateDistanceBetween(int left1, int top1, int right1, int bottom1, int left2, int top2, int right2, int bottom2)
The distance is calculated from the edge of the boxes. If the boxes overlap in a dimension, the delta in that dimension is zero.
left1
- the left of the first box.top1
- the top of the first box.right1
- the right of the first box.bottom1
- the bottom of the first box.left2
- the left of the second box.top2
- the top of the second box.right2
- the right of the second box.bottom2
- the bottom of the second box.