Java Utililty Methods Geometry Algorithm

List of utility methods to do Geometry Algorithm

  1. HOME
  2. Java
  3. G
  4. Geometry Algorithm

Description

The list of methods to do Geometry Algorithm are organized into topic(s).

Method

double absoluteBearing(Point2D source, Point2D target)
absolute Bearing
if (source == null || target == null) {
 return 0;
return Math.atan2(target.getX() - source.getX(), target.getY() - source.getY());
double absoluteBearing(Point2D.Double sourceLocation, Point2D.Double target)
absolute Bearing
return Math.atan2(target.x - sourceLocation.x, target.y - sourceLocation.y);
void applyCoG(Point2D.Double[] points, Point2D.Double cog)
apply Co G
for (int i = 0; i < points.length; i++) {
 points[i].setLocation(points[i].x - cog.x, points[i].y - cog.y);
Point[] applyDynamism(final Point[] spline, final int msForMove, final int msPerMove)
Omits points along the spline in order to move in steps rather then pixel by pixel
final int numPoints = spline.length;
final double msPerPoint = (double) msForMove / (double) numPoints;
final double undistStep = msPerMove / msPerPoint;
final int steps = (int) Math.floor(numPoints / undistStep);
final Point[] result = new Point[steps];
final double[] gaussValues = gaussTable(result.length);
double currentPercent = 0;
for (int i = 0; i < steps; i++) {
...
void applyMidPointApprox(CubicCurve2D cubic, QuadCurve2D quad)
Converts a cubic Bézier to a quadratic one, using the mid-point approximation
double a0x = cubic.getX1(), a0y = cubic.getY1();
double a1x = cubic.getX2(), a1y = cubic.getY2();
double p0x = (3 * cubic.getCtrlX1() - a0x) / 2.0;
double p0y = (3 * cubic.getCtrlY1() - a0y) / 2.0;
double p1x = (3 * cubic.getCtrlX2() - a1x) / 2.0;
double p1y = (3 * cubic.getCtrlY2() - a1y) / 2.0;
quad.setCurve(a0x, a0y, (p0x + p1x) / 2, (p0y + p1y) / 2, a1x, a1y);
Arc2D.Float arcThroughThreePoints(float x1, float y1, float x2, float y2, float x3, float y3, boolean clockwise)
arc Through Three Points
float d = 2 * (x1 - x3) * (y3 - y2) + 2 * (x2 - x3) * (y1 - y3);
float m1 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;
float m2 = x3 * x3 - x2 * x2 + y3 * y3 - y2 * y2;
float nx = m1 * (y3 - y2) + m2 * (y3 - y1);
float ny = m1 * (x2 - x3) + m2 * (x1 - x3);
float cx = nx / d;
float cy = ny / d;
float r = (float) Math.hypot(x1 - cx, y1 - cy);
...
double area2(Point2D a, Point2D b, Point2D c)
Calculates twice the area of a triangle for points specified in counter-clockwise order (if the points are specified in clockwise order the result will be negative).
double ax = a.getX();
double ay = a.getY();
double bx = b.getX();
double by = b.getY();
double cx = c.getX();
double cy = c.getY();
return (ax - cx) * (by - cy) - (ay - cy) * (bx - cx);
boolean AreAlign(Point2D.Double pivot, Point2D.Double a, Point2D.Double b)
Are Align
return (TriangleArea(pivot, a, b) == 0);
boolean areDifferentAnchorPoints(Point2D p1, Point2D p2)
are Different Anchor Points
return p1.distance(p2) > SAME_ANCHOR_POINT_THRESHOLD;
boolean areLocationsClose(Point2D point1, Point2D point2)
Checks if two locations are very close together.
double distance = getDistance(point1, point2);
return (distance < VERY_SMALL_DISTANCE);


AltStyle によって変換されたページ (->オリジナル) /