The following document contains the results of PMD's CPD 6.13.0.
File | Project | Line |
---|---|---|
com/github/davidmoten/rtree2/geometry/internal/LineDouble.java | rtree2 | 31 |
com/github/davidmoten/rtree2/geometry/internal/LineFloat.java | rtree2 | 31 |
return new LineDouble(x1, y1, x2, y2); } @Override public double distance(Rectangle r) { if (r.contains(x1, y1) || r.contains(x2, y2)) { return 0; } else { double d1 = distance(r.x1(), r.y1(), r.x1(), r.y2()); if (d1 == 0) return 0; double d2 = distance(r.x1(), r.y2(), r.x2(), r.y2()); if (d2 == 0) return 0; double d3 = distance(r.x2(), r.y2(), r.x2(), r.y1()); double d4 = distance(r.x2(), r.y1(), r.x1(), r.y1()); return Math.min(d1, Math.min(d2, Math.min(d3, d4))); } } private double distance(double x1, double y1, double x2, double y2) { Line2D line = new Line2D(x1, y1, x2, y2); double d1 = line.ptSegDist(this.x1, this.y1); double d2 = line.ptSegDist(this.x2, this.y2); Line2D line2 = new Line2D(this.x1, this.y1, this.x2, this.y2); double d3 = line2.ptSegDist(x1, y1); if (d3 == 0) return 0; double d4 = line2.ptSegDist(x2, y2); if (d4 == 0) return 0; else return Math.min(d1, Math.min(d2, Math.min(d3, d4))); } @Override public Rectangle mbr() { return Geometries.rectangle(Math.min(x1, x2), Math.min(y1, y2), Math.max(x1, x2), Math.max(y1, y2)); } @Override public boolean intersects(Rectangle r) { return RectangleUtil.rectangleIntersectsLine(r.x1(), r.y1(), r.x2() - r.x1(), r.y2() - r.y1(), x1, y1, x2, y2); } @Override public double x1() { return x1; } @Override public double y1() { return y1; } @Override public double x2() { return x2; } @Override public double y2() { return y2; } @Override public boolean intersects(Line b) { Line2D line1 = new Line2D(x1, y1, x2, y2); Line2D line2 = new Line2D(b.x1(), b.y1(), b.x2(), b.y2()); return line2.intersectsLine(line1); } @Override public boolean intersects(Point point) { return intersects(point.mbr()); } @Override public boolean intersects(Circle circle) { return GeometryUtil.lineIntersects(x1, y1, x2, y2, circle); } @Override public int hashCode() { return Objects.hashCode(x1, y1, x2, y2); } @Override public boolean equals(Object obj) { |
File | Project | Line |
---|---|---|
com/github/davidmoten/rtree2/geometry/internal/CircleDouble.java | rtree2 | 23 |
com/github/davidmoten/rtree2/geometry/internal/CircleFloat.java | rtree2 | 23 |
return new CircleDouble(x, y, radius); } @Override public double x() { return x; } @Override public double y() { return y; } @Override public double radius() { return radius; } @Override public Rectangle mbr() { return mbr; } @Override public double distance(Rectangle r) { return Math.max(0, GeometryUtil.distance(x, y, r) - radius); } @Override public boolean intersects(Rectangle r) { return distance(r) == 0; } @Override public boolean intersects(Circle c) { double total = radius + c.radius(); return GeometryUtil.distanceSquared(x, y, c.x(), c.y()) <= total * total; } @Override public int hashCode() { return Objects.hashCode(x, y, radius); } @Override public boolean equals(Object obj) { |
File | Project | Line |
---|---|---|
com/github/davidmoten/rtree2/geometry/internal/RectangleDouble.java | rtree2 | 49 |
com/github/davidmoten/rtree2/geometry/internal/RectangleFloat.java | rtree2 | 67 |
} @Override public boolean contains(double x, double y) { return x >= x1 && x <= x2 && y >= y1 && y <= y2; } @Override public boolean intersects(Rectangle r) { return GeometryUtil.intersects(x1, y1, x2, y2, r.x1(), r.y1(), r.x2(), r.y2()); } @Override public double distance(Rectangle r) { return GeometryUtil.distance(x1, y1, x2, y2, r.x1(), r.y1(), r.x2(), r.y2()); } @Override public Rectangle mbr() { return this; } @Override public String toString() { |
File | Project | Line |
---|---|---|
com/github/davidmoten/rtree2/geometry/internal/CircleDouble.java | rtree2 | 69 |
com/github/davidmoten/rtree2/geometry/internal/CircleFloat.java | rtree2 | 69 |
CircleDouble other = ObjectsHelper.asClass(obj, CircleDouble.class); if (other!=null) { return Objects.equal(x, other.x) && Objects.equal(y, other.y) && Objects.equal(radius, other.radius); } else return false; } @Override public boolean intersects(Point point) { return Math.sqrt(sqr(x - point.x()) + sqr(y - point.y())) <= radius; } private double sqr(double x) { return x * x; } @Override public boolean intersects(Line line) { return line.intersects(this); } @Override public boolean isDoublePrecision() { return true; |
File | Project | Line |
---|---|---|
com/github/davidmoten/rtree2/geometry/internal/PointDouble.java | rtree2 | 19 |
com/github/davidmoten/rtree2/geometry/internal/PointFloat.java | rtree2 | 18 |
return new PointDouble(x, y); } @Override public Rectangle mbr() { return this; } @Override public double distance(Rectangle r) { return GeometryUtil.distance(x, y, r); } @Override public boolean intersects(Rectangle r) { return r.x1() <= x && x <= r.x2() && r.y1() <= y && y <= r.y2(); } @Override public double x() { return x; } @Override public double y() { return y; } @Override public String toString() { |
File | Project | Line |
---|---|---|
com/github/davidmoten/rtree2/geometry/internal/PointDouble.java | rtree2 | 45 |
com/github/davidmoten/rtree2/geometry/internal/PointFloat.java | rtree2 | 69 |
} @Override public String toString() { return "Point [x=" + x() + ", y=" + y() + "]"; } @Override public Geometry geometry() { return this; } @Override public double x1() { return x; } @Override public double y1() { return y; } @Override public double x2() { return x; } @Override public double y2() { return y; } @Override public double area() { return 0; } @Override public Rectangle add(Rectangle r) { |