public class GeometricUtilities
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static float |
calcRotationAngleInDegrees(double centerX,
double centerY,
double targetX,
double targetY) |
static float |
calcRotationAngleInDegrees(java.awt.geom.Point2D centerPt,
java.awt.geom.Point2D targetPt)
Calculates the angle from centerPt to targetPt in degrees.
|
static boolean |
contains(java.awt.geom.Rectangle2D rectangle,
java.awt.geom.Point2D p)
Contains.
|
static double |
distance(double p1X,
double p1Y,
double p2X,
double p2Y) |
static double |
distance(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2) |
static double |
distance(java.awt.geom.Rectangle2D rect,
java.awt.geom.Point2D p)
Distance.
|
static boolean |
equals(java.awt.geom.Point2D point1,
java.awt.geom.Point2D point2,
double epsilon) |
static java.awt.geom.Rectangle2D |
extrude(java.awt.geom.Rectangle2D rect,
double ext) |
static java.awt.geom.Point2D |
getAveragePosition(java.util.Collection<java.awt.geom.Point2D> points) |
static java.awt.geom.Point2D |
getAveragePosition(java.awt.geom.Point2D... points) |
static java.awt.geom.Ellipse2D |
getCircle(java.awt.geom.Point2D center,
double radius) |
static java.awt.geom.Line2D[] |
getConnectingLines(java.awt.geom.Point2D point,
java.awt.geom.Point2D[] rectPoints) |
static java.util.List<java.awt.geom.Line2D.Double> |
getConstrainingLines(java.awt.geom.Area area) |
static float |
getDeltaX(double angle) |
static double |
getDeltaX(double angle,
double delta) |
static float |
getDeltaY(double angle) |
static double |
getDeltaY(double angle,
double delta) |
static double |
getDiagonal(java.awt.geom.Rectangle2D rect) |
static java.awt.geom.Point2D |
getIntersectionPoint(java.awt.geom.Line2D lineA,
java.awt.geom.Line2D lineB)
Gets the intersection point.
|
static java.awt.geom.Point2D |
getIntersectionPoint(java.awt.geom.Line2D line,
java.awt.geom.Rectangle2D rectangle)
Intersects.
|
static java.util.List<java.awt.geom.Point2D> |
getIntersectionPoints(java.awt.geom.Line2D line,
java.awt.geom.Rectangle2D rectangle)
Gets the intersection points.
|
static java.awt.geom.Line2D[] |
getLines(java.awt.geom.Rectangle2D rectangle)
Gets the lines.
|
static java.awt.geom.Point2D |
getMidPoint(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2) |
static java.awt.geom.Point2D |
getPerpendicularIntersection(java.awt.geom.Point2D point,
java.awt.geom.Line2D line)
Gets the perpendicular intersection.
|
static java.awt.geom.Point2D |
getPointOnCircle(java.awt.geom.Point2D center,
double radius,
double angle) |
static java.util.List<java.awt.geom.Point2D> |
getPoints(java.awt.geom.Path2D path) |
static java.util.List<java.awt.geom.Point2D> |
getPoints(java.awt.geom.Rectangle2D rectangle)
Gets the points.
|
static java.util.List<java.awt.geom.Point2D> |
getPointsBetweenPoints(java.awt.geom.Point2D point1,
java.awt.geom.Point2D point2)
Gets the points between the specified points using the Bresenham algorithm.
|
static boolean |
intersects(java.awt.geom.Ellipse2D a,
java.awt.geom.Ellipse2D b) |
static boolean |
intersects(java.awt.geom.Rectangle2D a,
java.awt.geom.Rectangle2D b) |
static double |
normalizeAngle(double angle)
Normalizes the specified angle to the range between 0-360 degree.
|
static java.awt.geom.Point2D |
project(java.awt.geom.Point2D start,
double angle,
double delta) |
static java.awt.geom.Point2D |
project(java.awt.geom.Point2D start,
java.awt.geom.Point2D end,
double scalar)
Projects a point from end along the vector (end - start) by the given
scalar amount.
|
static java.awt.geom.Point2D[] |
rayCastPoints(java.awt.geom.Point2D point,
java.awt.geom.Rectangle2D rectangle) |
static java.awt.Shape |
scaleRect(java.awt.geom.Rectangle2D shape,
int max) |
static java.awt.Shape |
scaleShape(java.awt.Shape shape,
double scale) |
static java.awt.geom.Dimension2D |
scaleWithRatio(double width,
double height,
int max) |
static boolean |
shapeIntersects(java.awt.Shape shapeA,
java.awt.Shape shapeB)
Shape intersects.
|
static java.awt.Shape |
translateShape(java.awt.Shape shape,
java.awt.geom.Point2D newLocation) |
public static float calcRotationAngleInDegrees(double centerX, double centerY, double targetX, double targetY)
public static float calcRotationAngleInDegrees(java.awt.geom.Point2D centerPt, java.awt.geom.Point2D targetPt)
centerPt
- Point we are rotating around.targetPt
- Point we want to calcuate the angle to.public static boolean contains(java.awt.geom.Rectangle2D rectangle, java.awt.geom.Point2D p)
rectangle
- the rectanglep
- the ppublic static double distance(double p1X, double p1Y, double p2X, double p2Y)
public static double distance(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)
public static double distance(java.awt.geom.Rectangle2D rect, java.awt.geom.Point2D p)
rect
- the rectp
- the ppublic static java.awt.geom.Rectangle2D extrude(java.awt.geom.Rectangle2D rect, double ext)
public static boolean equals(java.awt.geom.Point2D point1, java.awt.geom.Point2D point2, double epsilon)
public static java.awt.geom.Line2D[] getConnectingLines(java.awt.geom.Point2D point, java.awt.geom.Point2D[] rectPoints)
public static java.util.List<java.awt.geom.Line2D.Double> getConstrainingLines(java.awt.geom.Area area)
public static float getDeltaX(double angle)
public static float getDeltaY(double angle)
public static double getDeltaX(double angle, double delta)
public static double getDeltaY(double angle, double delta)
public static java.awt.geom.Point2D getIntersectionPoint(java.awt.geom.Line2D lineA, java.awt.geom.Line2D lineB)
lineA
- the line alineB
- the line bpublic static java.awt.geom.Point2D getIntersectionPoint(java.awt.geom.Line2D line, java.awt.geom.Rectangle2D rectangle)
line
- the linerectangle
- the rectanglepublic static java.util.List<java.awt.geom.Point2D> getIntersectionPoints(java.awt.geom.Line2D line, java.awt.geom.Rectangle2D rectangle)
line
- the linerectangle
- the rectanglepublic static java.awt.geom.Line2D[] getLines(java.awt.geom.Rectangle2D rectangle)
rectangle
- the rectanglepublic static double getDiagonal(java.awt.geom.Rectangle2D rect)
public static java.awt.geom.Point2D getMidPoint(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)
public static java.awt.geom.Ellipse2D getCircle(java.awt.geom.Point2D center, double radius)
public static java.awt.geom.Point2D getAveragePosition(java.util.Collection<java.awt.geom.Point2D> points)
public static java.awt.geom.Point2D getAveragePosition(java.awt.geom.Point2D... points)
public static java.awt.geom.Point2D getPerpendicularIntersection(java.awt.geom.Point2D point, java.awt.geom.Line2D line)
point
- the pointline
- the linepublic static java.awt.geom.Point2D getPointOnCircle(java.awt.geom.Point2D center, double radius, double angle)
public static java.util.List<java.awt.geom.Point2D> getPoints(java.awt.geom.Path2D path)
public static java.util.List<java.awt.geom.Point2D> getPoints(java.awt.geom.Rectangle2D rectangle)
rectangle
- the rectanglepublic static java.util.List<java.awt.geom.Point2D> getPointsBetweenPoints(java.awt.geom.Point2D point1, java.awt.geom.Point2D point2)
point1
- the point1point2
- the point2public static boolean intersects(java.awt.geom.Rectangle2D a, java.awt.geom.Rectangle2D b)
public static boolean intersects(java.awt.geom.Ellipse2D a, java.awt.geom.Ellipse2D b)
public static java.awt.geom.Point2D project(java.awt.geom.Point2D start, double angle, double delta)
public static java.awt.geom.Point2D project(java.awt.geom.Point2D start, java.awt.geom.Point2D end, double scalar)
start
- the startend
- the endscalar
- the scalarpublic static java.awt.geom.Point2D[] rayCastPoints(java.awt.geom.Point2D point, java.awt.geom.Rectangle2D rectangle)
public static java.awt.Shape scaleRect(java.awt.geom.Rectangle2D shape, int max)
public static java.awt.geom.Dimension2D scaleWithRatio(double width, double height, int max)
public static java.awt.Shape scaleShape(java.awt.Shape shape, double scale)
public static boolean shapeIntersects(java.awt.Shape shapeA, java.awt.Shape shapeB)
shapeA
- the shape ashapeB
- the shape bpublic static java.awt.Shape translateShape(java.awt.Shape shape, java.awt.geom.Point2D newLocation)
public static double normalizeAngle(double angle)
angle
- The angle that will be normalized.