List of utility methods to do Geometry Algorithm
void | assertEDT(String point) Assert that the current thread is the EDT. assert isEDT() : "EDT Violation : " + point + " must be called in EDT"; |
ArrayList | botCorners(Point2D.Double p) bot Corners ArrayList<Point2D.Double> corners = new ArrayList<Point2D.Double>(); corners.add(new Point2D.Double(p.x - BOT_HALF_WIDTH, p.y - BOT_HALF_WIDTH)); corners.add(new Point2D.Double(p.x - BOT_HALF_WIDTH, p.y + BOT_HALF_WIDTH)); corners.add(new Point2D.Double(p.x + BOT_HALF_WIDTH, p.y - BOT_HALF_WIDTH)); corners.add(new Point2D.Double(p.x + BOT_HALF_WIDTH, p.y + BOT_HALF_WIDTH)); return corners; |
Rectangle2D.Double | botRect(Point2D.Double botLocation) bot Rect Rectangle2D.Double botRect = new Rectangle2D.Double(botLocation.x - 18, botLocation.y - 18, 36, 36); return botRect; |
ArrayList | botSides(Point2D.Double botLocation) bot Sides ArrayList<Line2D.Double> botSides = new ArrayList<Line2D.Double>(); botSides.add( new Line2D.Double(botLocation.x - 18, botLocation.y - 18, botLocation.x + 18, botLocation.y - 18)); botSides.add( new Line2D.Double(botLocation.x + 18, botLocation.y - 18, botLocation.x + 18, botLocation.y + 18)); botSides.add( new Line2D.Double(botLocation.x + 18, botLocation.y + 18, botLocation.x - 18, botLocation.y + 18)); botSides.add( ... |
Rectangle | bound(Point... points) bound int smallestX = Integer.MAX_VALUE; int smallestY = Integer.MAX_VALUE; int largestX = Integer.MIN_VALUE; int largestY = Integer.MIN_VALUE; for (Point point : points) { if (point == null) { continue; if (point.x > largestX) largestX = point.x; if (point.y > largestY) largestY = point.y; if (point.x < smallestX) smallestX = point.x; if (point.y < smallestY) smallestY = point.y; return new Rectangle(smallestX, smallestY, largestX - smallestX, largestY - smallestY); |
Rectangle2D | boundingBox(Vector bounding Box double minX = Double.MAX_VALUE; double minY = Double.MAX_VALUE; double maxX = Double.MIN_VALUE; double maxY = Double.MIN_VALUE; Point2D next; for (Iterator<Point2D> iterator = points.iterator(); iterator.hasNext();) { next = iterator.next(); minX = Math.min(minX, next.getX()); ... |
Rectangle | boundsOf(Collection extends Point> points) Report the bounding box for all points if ((points == null) || points.isEmpty()) { return null; Rectangle bounds = null; for (Point point : points) { if (bounds == null) { bounds = new Rectangle(point); } else { ... |
java.awt.geom.Point2D.Double | cap(java.awt.geom.Point2D.Double p1, java.awt.geom.Point2D.Double p2, double radius) cap double angle = 1.5707963267948966D - Math.atan2(p2.x - p1.x, p2.y - p1.y); java.awt.geom.Point2D.Double p3 = new java.awt.geom.Point2D.Double(p2.x + radius * Math.cos(angle), p2.y + radius * Math.sin(angle)); return p3; |
Point2D | centroid(Vector centroid double sumX = 0; double sumY = 0; for (Iterator<Point2D> iterator = points.iterator(); iterator.hasNext();) { Point2D next = iterator.next(); sumX += next.getX(); sumY += next.getY(); int length = points.size(); ... |
boolean | checkPoint(Point p) check Point return clip.contains(p);
|