public class GeomUtil extends Object
| Constructor and Description |
|---|
GeomUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
dot(int vsx,
int vsy,
int v1ex,
int v1ey,
int v2ex,
int v2ey)
Computes and returns the dot product of the two vectors.
|
static int |
dot(int v1sx,
int v1sy,
int v1ex,
int v1ey,
int v2sx,
int v2sy,
int v2ex,
int v2ey)
Computes and returns the dot product of the two vectors.
|
static int |
dot(Point vs,
Point v1e,
Point v2e)
Computes and returns the dot product of the two vectors.
|
static int |
dot(Point v1s,
Point v1e,
Point v2s,
Point v2e)
Computes and returns the dot product of the two vectors.
|
static Rectangle |
getTile(int width,
int height,
int tileWidth,
int tileHeight,
int tileIndex)
Returns the rectangle containing the specified tile in the supplied larger rectangle.
|
static void |
getTile(int width,
int height,
int tileWidth,
int tileHeight,
int tileIndex,
Rectangle bounds)
Fills in the bounds of the specified tile in the supplied larger rectangle.
|
static Rectangle |
grow(Rectangle source,
Rectangle target)
Adds the target rectangle to the bounds of the source rectangle.
|
static boolean |
lineIntersection(Point2D p1,
Point2D p2,
boolean seg1,
Point2D p3,
Point2D p4,
boolean seg2,
Point2D result)
Calculate the intersection of two lines.
|
static Point |
nearestToLine(Point p1,
Point p2,
Point p3,
Point n)
Computes the point nearest to the specified point
p3 on the line defined by the
two points p1 and p2. |
static void |
shiftToContain(Rectangle tainer,
Rectangle tained)
Shifts the position of the
tainer rectangle to ensure that it contains the
tained rectangle. |
static int |
whichSide(Point p1,
double theta,
Point p2)
Returns less than zero if
p2 is on the left hand side of the line created by
p1 and theta and greater than zero if it is on the right hand
side. |
public static int dot(Point v1s, Point v1e, Point v2s, Point v2e)
v1s - the starting point of the first vector.v1e - the ending point of the first vector.v2s - the starting point of the second vector.v2e - the ending point of the second vector.public static int dot(int v1sx,
int v1sy,
int v1ex,
int v1ey,
int v2sx,
int v2sy,
int v2ex,
int v2ey)
dot(Point,Point,Point,Point) for an explanation of the argumentspublic static int dot(Point vs, Point v1e, Point v2e)
vs - the starting point of both vectors.v1e - the ending point of the first vector.v2e - the ending point of the second vector.public static int dot(int vsx,
int vsy,
int v1ex,
int v1ey,
int v2ex,
int v2ey)
dot(Point,Point,Point) for an explanation of the argumentspublic static Point nearestToLine(Point p1, Point p2, Point p3, Point n)
p3 on the line defined by the
two points p1 and p2. The computed point is stored into
n. Note: p1 and p2 must not be coincident.p1 - one point on the line.p2 - another point on the line (not equal to p1).p3 - the point to which we wish to be most near.n - the point on the line defined by p1 and p2 that is
nearest to p.n.public static boolean lineIntersection(Point2D p1, Point2D p2, boolean seg1, Point2D p3, Point2D p4, boolean seg2, Point2D result)
p1 - and p2 the coordinates of the first line.seg1 - if the first line should be considered a segment.p3 - and p4 the coordinates of the second line.seg2 - if the second line should be considered a segment.result - the point that will be filled in with the intersecting point.public static int whichSide(Point p1, double theta, Point p2)
p2 is on the left hand side of the line created by
p1 and theta and greater than zero if it is on the right hand
side. In theory, it will return zero if the point is on the line, but due to rounding errors
it almost always decides that it's not exactly on the line.p1 - the point on the line whose side we're checking.theta - the (logical) angle defining the line.p2 - the point that lies on one side or the other of the line.public static void shiftToContain(Rectangle tainer, Rectangle tained)
tainer rectangle to ensure that it contains the
tained rectangle. The tainer rectangle must be larger than or
equal to the size of the tained rectangle.public static Rectangle grow(Rectangle source, Rectangle target)
public static Rectangle getTile(int width, int height, int tileWidth, int tileHeight, int tileIndex)
public static void getTile(int width,
int height,
int tileWidth,
int tileHeight,
int tileIndex,
Rectangle bounds)
Copyright © 2015. All rights reserved.