| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectaim4.util.GeomMath
public final class GeomMath
Class of static utility methods for geometric computation.
| Nested Class Summary | |
|---|---|
static class | 
GeomMath.IntersectionPoint
A class for storing the result of findLineLineIntersection.  | 
| Field Summary | |
|---|---|
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  | 
| Method Summary | |
|---|---|
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.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
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
| Method Detail | 
|---|
public static String ordinalize(int num)
num - the cardinal number
public static double canonicalAngle(double angle)
angle - the angle
public static double angleToPoint(Point2D p,
                                  Point2D startPoint)
p - the point to which to find the anglestartPoint - the point from which to start
public 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 point
public static Point2D subtract(Point2D p1,
                               Point2D p2)
p1 - the first vectorp2 - the second vector
public static double dotProduct(Point2D p1,
                                Point2D p2)
p1 - the first vectorp2 - the second vector
public static double crossProduct(Point2D p1,
                                  Point2D p2)
p1 - the first vectorp2 - the second vector
public static Point2D findLineLineIntersection(Line2D l1,
                                               Line2D l2)
l1 - the first linel2 - the second line
public 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 line
public 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 line
public static List<List<Point2D>> polygonalSubShapeVertices(Shape s)
s - the polygonal Shape
IllegalArgumentException - if the Shape is not polygonalpublic static List<Line2D> polygonalShapePerimeterSegments(Shape s)
s - the polygonal Shape
IllegalArgumentException - if the Shape is not polygonalpublic static List<Double> polygonalShapeAreas(Shape s)
s - the polygonal Shape
public static Point2D polygonalShapeCentroid(Shape s)
s - the polygonal Shape
public static Point2D centroid(List<Point2D> points)
points - the List of Points
public static Area filledArea(Shape s)
subareas(Shape s).
s - the Shape to fill in
public 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 term
public 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 interval
public static double angleDiff(double ang1,
                               double ang2)
ang1 - the first angleang2 - the second angle
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||