AI for Games 1.1.1
|
Static Public Member Functions | |
static void | point_to_line_dist (double nearness) |
static boolean | is_point_near_line (Vector2D v0, Vector2D v1, Vector2D p) |
static boolean | is_point_near_line (Vector2D v0, Vector2D v1, Vector2D p, Vector2D vp) |
static boolean | is_point_near_infinite_line (Vector2D v0, Vector2D v1, Vector2D p) |
static boolean | is_point_near_infinite_line (Vector2D v0, Vector2D v1, Vector2D p, Vector2D vp) |
static Vector2D | point_nearest_line (Vector2D v0, Vector2D v1, Vector2D p) |
static Vector2D | point_nearest_infinite_line (Vector2D v0, Vector2D v1, Vector2D p) |
static boolean | line_circle (double x0, double y0, double x1, double y1, double cx, double cy, double r) |
static double[] | line_circle_p (double x0, double y0, double x1, double y1, double cx, double cy, double r) |
static boolean | line_line (double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3) |
static Vector2D | line_line_p (Vector2D v0, Vector2D v1, Vector2D v2, Vector2D v3) |
static Vector2D | line_line_infinite_p (Vector2D v0, Vector2D v1, Vector2D v2, Vector2D v3) |
static double[] | line_line_p (double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3) |
static double[] | line_line_infinite_p (double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3) |
static double[] | line_lines_p (double x0, double y0, double x1, double y1, double[] xy, boolean continuous) |
static boolean | circle_circle (double cx0, double cy0, double r0, double cx1, double cy1, double r1) |
static double[] | circle_circle_p (double cx0, double cy0, double r0, double cx1, double cy1, double r1) |
static double[] | tangents_to_circle (double x, double y, double cx, double cy, double r) |
static double[] | tangents_between_circles (double cx0, double cy0, double r0, double cx1, double cy1, double r1) |
static int | which_side_pp (double x0, double y0, double x1, double y1, double px, double py) |
static int | which_side_pn (double x0, double y0, double nx, double ny, double px, double py) |
static boolean | line_box_xyxy (double lx0, double ly0, double lx1, double ly1, double rx0, double ry0, double rx1, double ry1) |
static boolean | line_box_xywh (double lx0, double ly0, double lx1, double ly1, double rx0, double ry0, double rWidth, double rHeight) |
static boolean | box_box (double ax0, double ay0, double ax1, double ay1, double bx0, double by0, double bx1, double by1) |
static double[] | box_box_p (double ax0, double ay0, double ax1, double ay1, double bx0, double by0, double bx1, double by1) |
static boolean | isInsideTriangle (double aX, double aY, double bX, double bY, double cX, double cY, double pX, double pY) |
static boolean | isInsideTriangle (Vector2D a, Vector2D b, Vector2D c, Vector2D p) |
static boolean | isInsideTriangle (Vector2D a, Vector2D b, Vector2D c, double pX, double pY) |
static boolean | isInsideRectangle_xyxy (double x0, double y0, double x1, double y1, double pX, double pY) |
static boolean | isInsideRectangle_xyxy (Vector2D v0, Vector2D v1, Vector2D p) |
static boolean | isInsideRectangle_xywh (double x0, double y0, double width, double height, double pX, double pY) |
static boolean | isInsideRectangle_xywh (Vector2D v0, double width, double height, Vector2D p) |
static boolean | isInsidePolygon (Vector2D[] verts, double x0, double y0) |
static double | distance_sq (double x0, double y0, double x1, double y1) |
static double | distance (double x0, double y0, double x1, double y1) |
Static Public Attributes | |
static final int | ON_PLANE = 16 |
static final int | PLANE_INSIDE = 17 |
static final int | PLANE_OUTSIDE = 18 |
Static Private Member Functions | |
static int | outcode (double pX, double pY, double rectX, double rectY, double rectWidth, double rectHeight) |
|
static |
Determine whether two boxes intersect.
The boxes are represented by the top-left and bottom-right corner coordinates.
ax0 | top-left corner of rectangle A |
ay0 | top-left corner of rectangle A |
ax1 | bottom-right corner of rectangle A |
ay1 | bottom-right corner of rectangle A |
bx0 | top-left corner of rectangle B |
by0 | top-left corner of rectangle B |
bx1 | bottom-right corner of rectangle B |
by1 | bottom-right corner of rectangle B |
|
static |
If two boxes overlap then the overlap region is another box. This method is used to calculate the coordinates of the overlap.
The boxes are represented by the top-left and bottom-right corner coordinates. If the returned array has a length: 0 then they do not overlap
4 then these are the coordinates of the top-left and bottom-right corners of the overlap region.
ax0 | top-left corner of rectangle A |
ay0 | top-left corner of rectangle A |
ax1 | bottom-right corner of rectangle A |
ay1 | bottom-right corner of rectangle A |
bx0 | top-left corner of rectangle B |
by0 | top-left corner of rectangle B |
bx1 | bottom-right corner of rectangle B |
by1 | bottom-right corner of rectangle B |
|
static |
Determine if two circles overlap
cx0 | centre of first circle x position |
cy0 | centre of first circle y position |
r0 | radius of first circle |
cx1 | centre of second circle x position |
cy1 | centre of second circle y position |
r1 | radius of second circle |
|
static |
Calculate the intersection points between two circles.
If the array is of length:
0 then there is no intersection
2 there is just one intersection (the circles are touching)
4 there are two intersections
cx0 | centre of first circle x position |
cy0 | centre of first circle y position |
r0 | radius of first circle |
cx1 | centre of second circle x position |
cy1 | centre of second circle y position |
r1 | radius of second circle |
|
static |
Calculates the distance between 2 points
x0 | point 1 |
y0 | point 1 |
x1 | point 2 |
y1 | point 2 |
|
static |
Calculates the squared distance between 2 points
x0 | point 1 |
y0 | point 1 |
x1 | point 2 |
y1 | point 2 |
|
static |
See if point is near the infinite line.
v0 | line passes through this point |
v1 | line passes through this point |
p | point to consider |
|
static |
See if point is near the infinite line.
v0 | line passes through this point |
v1 | line passes through this point |
p | point to consider |
vp | filled with xy position of the nearest point on line (must not be null) |
|
static |
See if point is near the finite line.
v0 | line start |
v1 | line end |
p | point to consider |
|
static |
See if point is near the finite line.
v0 | line start |
v1 | line end |
p | point to consider |
vp | filled with xy position of the nearest point on finite line (must not be null) |
|
static |
See if the given point is inside a polygon defined by the vertices provided.
verts | the vertices of the shape |
x0 | |
y0 |
|
static |
See if a point is inside the rectangle defined by top-left and bottom right coordinates
x0 | top-left corner of rectangle |
y0 | top-left corner of rectangle |
width | width of rectangle |
height | height of rectangle |
pX | x position of point of interest |
pY | y position of point of interest |
|
static |
See if this a is inside the rectangle defined by top-left and bottom right coordinates
v0 | top-left corner of rectangle |
width | width of rectangle |
height | height of rectangle |
p | point of interest |
|
static |
See if a point is inside the rectangle defined by top-left and bottom right coordinates
x0 | top-left corner of rectangle |
y0 | top-left corner of rectangle |
x1 | bottom-right corner of rectangle |
y1 | bottom-right corner of rectangle |
pX | x position of point of interest |
pY | y position of point of interest |
|
static |
See if this a is inside the rectangle defined by top-left and bottom right coordinates
v0 | top-left corner of rectangle |
v1 | bottom-right corner of rectangle |
p | point of interest |
|
static |
Determine if the point pX/pY is inside triangle defined by triangle ABC whose vertices are given by [ax,ay] [bx,by] [cx,cy]
|
static |
Determine if the point pX/pY is inside triangle defined by triangle ABC
a | triangle vertex 1 |
b | triangle vertex 2 |
c | triangle vertex 3 |
pX | x position for point of interest |
pY | y position for point of interest |
|
static |
Determine if the point (p) is inside triangle defined by triangle ABC
a | triangle vertex 1 |
b | triangle vertex 2 |
c | triangle vertex 3 |
p | point of interest |
|
static |
Determine whether a line intersects with a box.
The box is represented by the top-left corner coordinates and the box width and height.
lx0 | start of line |
ly0 | start of line |
lx1 | end of line |
ly1 | end of line |
rx0 | top-left corner of rectangle |
ry0 | top-left corner of rectangle |
rWidth | width of rectangle |
rHeight | height of rectangle |
|
static |
Determine whether a line intersects with a box.
The box is represented by the top-left and bottom-right corner coordinates.
lx0 | start of line |
ly0 | start of line |
lx1 | end of line |
ly1 | end of line |
rx0 | top-left corner of rectangle |
ry0 | top-left corner of rectangle |
rx1 | bottom-right corner of rectangle |
ry1 | bottom-right corner of rectangle |
|
static |
Sees if a line intersects with the circumference of a circle.
x0 | |
y0 | |
x1 | |
y1 | |
cx | centre of circle x position |
cy | centre of circle y position |
r | radius of circle |
|
static |
Calculate the points of intersection between a line and a circle.
An array is returned that contains the intersection points in x, y order. If the array is of length:
0 then there is no intersection
2 there is just one intersection (the line is a tangent to the circle)
4 there are two intersections
x0 | start of line |
y0 | start of line |
x1 | end of line |
y1 | end of line |
cx | centre of circle x position |
cy | centre of circle y position |
r | radius of circle |
|
static |
See if two lines intersect
x0 | start of line 1 |
y0 | start of line 1 |
x1 | end of line 1 |
y1 | end of line 1 |
x2 | start of line 2 |
y2 | start of line 2 |
x3 | end of line 2 |
y3 | end of line 2 |
|
static |
Find the point of intersection between two infinite lines that pass through the points ([x0,y0],[x1,y1]) and ([x2,y2],[x3,y3]).
An array is returned that contains the intersection points in x, y order. If the array is of length:
0 then there is no intersection
2 these are the x/y coordinates of the intersection point.
|
static |
Find the intersection point between two infinite lines that pass through the points (v0,v1) and (v2,v3)
|
static |
Find the point of intersection between two lines.
An array is returned that contains the intersection points in x, y order. If the array is of length:
0 then there is no intersection
2 these are the x/y coordinates of the intersection point.
x0 | start of line 1 |
y0 | start of line 1 |
x1 | end of line 1 |
y1 | end of line 1 |
x2 | start of line 2 |
y2 | start of line 2 |
x3 | end of line 2 |
y3 | end of line 2 |
|
static |
Find the point of intersection between two lines.
This method uses Vector2D objects to represent the line end points.
v0 | start of line 1 |
v1 | end of line 1 |
v2 | start of line 2 |
v3 | end of line 2 |
|
static |
Calculate the intersection points between a line and a collection of lines.
This will calculate all the intersection points between a given line and the lines formed from the points in the array xy.
If the parameter continuous = true the points form a continuous line so the
line 1 is from xy[0],xy[1] to xy[2],xy[3] and line 2 is from xy[2],xy[3] to xy[4],xy[5] and so on
and if continuous is false then each set of four array elements form their own line
line 1 is from xy[0],xy[1] to xy[2],xy[3] and line 2 is from xy[4],xy[5] to xy[6],xy[7] and so on
x0 | x position of the line start |
y0 | y position of the line start |
x1 | x position of the line end |
y1 | y position of the line end |
xy | array of x/y coordinates |
continuous | if true the points makes a continuous line |
|
staticprivate |
|
static |
Given a point find the nearest position on an infinite line.
v0 | line start |
v1 | line end |
p | point to consider |
|
static |
Given a point find the nearest position on a finite line.
v0 | line start |
v1 | line end |
p | point to consider |
|
static |
This sets the distance used to decide whether a point is 'near, a line. This is initially set at 1.0
nearness | must be >0 otherwise it is unchanged |
|
static |
Will calculate the contact points for both outer and inner tangents.
There are no tangents if one circle is completely inside the other. If the circles interact only the outer tangents exist. When the circles do not intersect there will be 4 tangents (outer and inner), the array has the outer pair first.
cx0 | x position for the first circle |
cy0 | y position for the first circle |
r0 | radius of the first circle |
cx1 | x position for the second circle |
cy1 | y position for the second circle |
r1 | radius of the second circle |
|
static |
Calculate the tangents from a point.
If the array is of length:
0 then there is no tangent the point is inside the circle
2 there is just one intersection (the point is on the circumference)
4 there are two points.
x | x position for point of interest |
y | y position for point of interest |
cx | centre of circle x position |
cy | centre of circle y position |
r | radius of circle |
|
static |
Outside is in the same direction of the plane normal.
This version requires a single point on the plane and the normal direction. Useful for an infinite plane or for testing many points against a single plane when the plane normal does not have to be calculated each time.
x0 | x position point of a point on the plane |
y0 | y position point of a point on the plane |
nx | x value of normal vector |
ny | y value of normal vector |
px | x position of the point to test |
py | y position of the point to test |
|
static |
Outside is in the same direction of the plane normal.
The first four parameters represent the start and end position for a line segment (finite plane).
x0 | x start of the line |
y0 | y start of the line |
x1 | x end of the line |
y1 | y end of the line |
px | x position of the point to test |
py | y position of the point to test |