@Override public String toString() { return "[" + getX() + "," + getY() + "]"; }
public int hashCode() { long bits = java.lang.Double.doubleToLongBits(getX()); bits ^= java.lang.Double.doubleToLongBits(getY()) * 31; return (((int) bits) ^ ((int) (bits >> 32))); }
private static boolean isShallow( DTSweepContext tcx, AdvancingFrontNode node ) { double height; if( tcx.basin.leftHighest ) { height = tcx.basin.leftNode.getPoint().getY() - node.getPoint().getY(); } else { height = tcx.basin.rightNode.getPoint().getY() - node.getPoint().getY(); } if( tcx.basin.width > height ) { return true; } return false; }
/** * Forumla to calculate signed area<br> * Positive if CCW<br> * Negative if CW<br> * 0 if collinear<br> * <pre> * A[P1,P2,P3] = (x1*y2 - y1*x2) + (x2*y3 - y2*x3) + (x3*y1 - y3*x1) * = (x1-x3)*(y2-y3) - (y1-y3)*(x2-x3) * </pre> */ public static Orientation orient2d( TriangulationPoint pa, TriangulationPoint pb, TriangulationPoint pc ) { double detleft = ( pa.getX() - pc.getX() ) * ( pb.getY() - pc.getY() ); double detright = ( pa.getY() - pc.getY() ) * ( pb.getX() - pc.getX() ); double val = detleft - detright; if( val > -EPSILON && val < EPSILON ) { return Orientation.Collinear; } else if( val > 0 ) { return Orientation.CCW; } return Orientation.CW; }
/** * * @param node - middle node * @return the angle between p-a and p-b in range [-pi,pi] */ private static double angle( TriangulationPoint p, TriangulationPoint a, TriangulationPoint b ) { // XXX: do we really need a signed angle for holeAngle? // could possible save some cycles here /* Complex plane * ab = cosA +i*sinA * ab = (ax + ay*i)(bx + by*i) = (ax*bx + ay*by) + i(ax*by-ay*bx) * atan2(y,x) computes the principal value of the argument function * applied to the complex number x+iy * Where x = ax*bx + ay*by * y = ax*by - ay*bx */ final double px = p.getX(); final double py = p.getY(); final double ax = a.getX() - px; final double ay = a.getY() - py; final double bx = b.getX() - px; final double by = b.getY() - py; return Math.atan2( ax*by - ay*bx, ax*bx + ay*by ); }
private static List<Triangle2d> convert(Polygon p) { List<DelaunayTriangle> triangles = p.getTriangles(); if (triangles == null || triangles.size() == 0) { return null; } List<Triangle2d> out = new ArrayList<Triangle2d>(); for (DelaunayTriangle t : triangles) { Triangle2d triangle = new Triangle2d( new Point2d(t.points[0].getX(), t.points[0].getY()), new Point2d(t.points[1].getX(), t.points[1].getY()), new Point2d(t.points[2].getX(), t.points[2].getY())); out.add(triangle); } return out; }