public final class GeomMath extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
GeomMath.IntersectionPoint
A class for storing the result of findLineLineIntersection.
|
| Modifier and Type | Field and Description |
|---|---|
static double |
HALF_PI
Math.PI / 2.0
|
static double |
ONE_AND_HALF_PI
Math.PI * 3.0 / 2.0
|
static double |
PI
Math.PI
|
static double |
QUARTER_PI
Math.PI / 4.0
|
static double |
TWO_PI
Math.PI * 2.0
|
| Modifier and Type | Method and Description |
|---|---|
static double |
angleDiff(double ang1,
double ang2)
Determine the angle between two angles.
|
static double |
angleToPoint(Point2D p,
Point2D startPoint)
Find the angle of the heading to a point from a given starting point.
|
static double |
canonicalAngle(double angle)
Get the "canonical" angle.
|
static Point2D |
centroid(List<Point2D> points)
Find the centroid of a list of points.
|
static double |
crossProduct(Point2D p1,
Point2D p2)
Compute the cross product of two 2D vectors.
|
static double |
dotProduct(Point2D p1,
Point2D p2)
Compute the dot product of two 2D vectors.
|
static Area |
filledArea(Shape s)
Find the Area corresponding to the provided Shape with all
holes filled in.
|
static Point2D |
findLineLineIntersection(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double x4,
double y4)
Compute the intersection of two lines defined by two points each.
|
static Point2D |
findLineLineIntersection(Line2D l1,
Line2D l2)
Compute the intersection of two lines.
|
static GeomMath.IntersectionPoint |
findLineLineIntersection(Point2D p1,
double slope1,
Point2D p2,
double slope2)
Compute the intersection of two lines defined by two points each.
|
static boolean |
intervalsOverlap(double t1start,
double t1end,
double t2start,
double t2end)
Determine whether two intervals overlap.
|
static String |
ordinalize(int num)
Turn a cardinal number into an ordinal number.
|
static Point2D |
polarAdd(Point2D p,
double r,
double theta)
Find a point displaced by the given distance in the given direction.
|
static List<Double> |
polygonalShapeAreas(Shape s)
Given a polygonal, non-overlapping Shape, return the areas of the closed
portions of the shape.
|
static Point2D |
polygonalShapeCentroid(Shape s)
Given a polygonal Shape, return the centroid of the shape.
|
static List<Line2D> |
polygonalShapePerimeterSegments(Shape s)
Given a polygonal Shape, return a list of segments describing its
perimeter.
|
static List<List<Point2D>> |
polygonalSubShapeVertices(Shape s)
Given a polygonal Shape, return a list of lists of points that are the
vertices of the closed polygonal sub-shapes.
|
static double |
quadraticFormula(double a,
double b,
double c)
Solve the quadratic formula ax2 + bx + c = 0
given coefficients a, b, and c, returning the minimum nonnegative
root, or the largest root if both are negative.
|
static List<Area> |
subareas(Shape s)
Find all the subareas of a Shape.
|
static Point2D |
subtract(Point2D p1,
Point2D p2)
Subtract two 2D vectors.
|
public static final double QUARTER_PI
public static final double HALF_PI
public static final double PI
public static final double ONE_AND_HALF_PI
public static final double TWO_PI
public static String ordinalize(int num)
num - the cardinal numberpublic static double canonicalAngle(double angle)
angle - the anglepublic static double angleToPoint(Point2D p, Point2D startPoint)
p - the point to which to find the anglestartPoint - the point from which to startpublic static Point2D polarAdd(Point2D p, double r, double theta)
p - the starting pointr - the distance to move from the pointtheta - the angle at which to move from the pointpublic static Point2D subtract(Point2D p1, Point2D p2)
p1 - the first vectorp2 - the second vectorpublic static double dotProduct(Point2D p1, Point2D p2)
p1 - the first vectorp2 - the second vectorpublic static double crossProduct(Point2D p1, Point2D p2)
p1 - the first vectorp2 - the second vectorpublic static Point2D findLineLineIntersection(Line2D l1, Line2D l2)
l1 - the first linel2 - the second linepublic static Point2D findLineLineIntersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
x1 - the x coordinate of the first point of the first liney1 - the y coordinate of the first point of the first linex2 - the x coordinate of the second point of the first liney2 - the y coordinate of the second point of the first linex3 - the x coordinate of the first point of the second liney3 - the y coordinate of the first point of the second linex4 - the x coordinate of the second point of the second liney4 - the y coordinate of the second point of the second linepublic static GeomMath.IntersectionPoint findLineLineIntersection(Point2D p1, double slope1, Point2D p2, double slope2)
p1 - an intercepting point of the first lineslope1 - the slope of the first linep2 - an intercepting point of the second lineslope2 - the slope of the second linepublic static List<List<Point2D>> polygonalSubShapeVertices(Shape s)
s - the polygonal ShapeIllegalArgumentException - if the Shape is not polygonalpublic static List<Line2D> polygonalShapePerimeterSegments(Shape s)
s - the polygonal ShapeIllegalArgumentException - if the Shape is not polygonalpublic static List<Double> polygonalShapeAreas(Shape s)
s - the polygonal Shapepublic static Point2D polygonalShapeCentroid(Shape s)
s - the polygonal Shapepublic static Point2D centroid(List<Point2D> points)
points - the List of Pointspublic static Area filledArea(Shape s)
subareas(Shape s).s - the Shape to fill inpublic static List<Area> subareas(Shape s)
s - the Shape to deconstruct.public static double quadraticFormula(double a,
double b,
double c)
a - the coefficient of the x2 termb - the coefficient of the x termc - the constant termpublic static boolean intervalsOverlap(double t1start,
double t1end,
double t2start,
double t2end)
t1start - the start of the first intervalt1end - the end of the first intervalt2start - the start of the second intervalt2end - the end of the second intervalpublic static double angleDiff(double ang1,
double ang2)
ang1 - the first angleang2 - the second angleCopyright © 2013. All rights reserved.