@Test public void testIntersect() { ProjectionRect rect = new ProjectionRect(); assertThat( rect.intersects(ProjectionRect.builder().setRect(-4.502221, -4.570379, 3925.936303, 2148.077947).build())) .isTrue(); assertThat(rect.intersects(ProjectionRect.builder().setRect(-6000, -6000, 500, 500).build())).isFalse(); assertThat(rect.intersects(ProjectionRect.builder().setRect(-6000, -500, 500, 1000).build())).isFalse(); assertThat(rect.intersects(ProjectionRect.builder().setRect(-500, -6000, 5000, 500).build())).isFalse(); ProjectionRect rect2 = new ProjectionRect().toBuilder().setX(-6000).setY(-6000).build(); assertThat(ProjectionRect.intersect(rect, rect2).isEmpty()).isFalse(); assertThat(ProjectionRect.intersect(rect, rect2)).isEqualTo(new ProjectionRect("-5000, -5000, 9000, 9000")); ProjectionRect rect3 = new ProjectionRect().toBuilder().setX(-6000).setY(6000).build(); assertThat(ProjectionRect.intersect(rect, rect3).isEmpty()).isTrue(); assertThat(ProjectionRect.intersect(rect, rect3)).isEqualTo(new ProjectionRect("-5000, 6000, 9000, -1000")); }
public static ProjectionRect intersect(ProjectionRect src1, ProjectionRect src2) { double x1 = Math.max(src1.getMinX(), src2.getMinX()); double y1 = Math.max(src1.getMinY(), src2.getMinY()); double x2 = Math.min(src1.getMaxX(), src2.getMaxX()); double y2 = Math.min(src1.getMaxY(), src2.getMaxY()); return builder().setX(x1).setY(y1).setWidth(x2 - x1).setHeight(y2 - y1).build(); }
ProjectionRect { public static ProjectionRect intersect(ProjectionRect src1, ProjectionRect src2) { double x1 = Math.max(src1.getMinX(), src2.getMinX()); double y1 = Math.max(src1.getMinY(), src2.getMinY()); double x2 = Math.min(src1.getMaxX(), src2.getMaxX()); double y2 = Math.min(src1.getMaxY(), src2.getMaxY()); return builder().setX(x1).setY(y1).setWidth(x2 - x1).setHeight(y2 - y1).build(); } }
ProjectionRect { public static ProjectionRect intersect(ProjectionRect src1, ProjectionRect src2) { double x1 = Math.max(src1.getMinX(), src2.getMinX()); double y1 = Math.max(src1.getMinY(), src2.getMinY()); double x2 = Math.min(src1.getMaxX(), src2.getMaxX()); double y2 = Math.min(src1.getMaxY(), src2.getMaxY()); return builder().setX(x1).setY(y1).setWidth(x2 - x1).setHeight(y2 - y1).build(); } ProjectionRect();  ProjectionRect(ProjectionPoint corner1, ProjectionPoint corner2);  ProjectionRect(ProjectionPoint minimum, double width, double height);  ProjectionRect(double x1, double y1, double x2, double y2);  ProjectionRect(String spec); private  ProjectionRect(ProjectionRect.Builder builder); }
ProjectionRect { public static ProjectionRect intersect(ProjectionRect src1, ProjectionRect src2) { double x1 = Math.max(src1.getMinX(), src2.getMinX()); double y1 = Math.max(src1.getMinY(), src2.getMinY()); double x2 = Math.min(src1.getMaxX(), src2.getMaxX()); double y2 = Math.min(src1.getMaxY(), src2.getMaxY()); return builder().setX(x1).setY(y1).setWidth(x2 - x1).setHeight(y2 - y1).build(); } ProjectionRect();  ProjectionRect(ProjectionPoint corner1, ProjectionPoint corner2);  ProjectionRect(ProjectionPoint minimum, double width, double height);  ProjectionRect(double x1, double y1, double x2, double y2);  ProjectionRect(String spec); private  ProjectionRect(ProjectionRect.Builder builder); @Deprecated double getX(); @Deprecated double getY(); double getWidth(); double getHeight(); double getMinX(); double getMinY(); double getMaxX(); double getMaxY(); double getCenterX(); double getCenterY(); boolean isEmpty(); boolean intersects(ProjectionRect r); boolean intersects(double x, double y, double w, double h); static ProjectionRect intersect(ProjectionRect src1, ProjectionRect src2); boolean contains(ProjectionPoint point); boolean contains(ProjectionRect rect); ProjectionPoint getLowerRightPoint(); ProjectionPoint getUpperRightPoint(); ProjectionPoint getLowerLeftPoint(); ProjectionPoint getUpperLeftPoint(); ProjectionPoint getMinPoint(); ProjectionPoint getMaxPoint(); String toString(); String toString2(int ndec); String toStringSpec(); @Override boolean equals(Object o); @Override int hashCode(); boolean nearlyEquals(ProjectionRect other); boolean nearlyEquals(ProjectionRect other, double maxRelDiff); ProjectionRect.Builder toBuilder(); static Builder builder(); static Builder builder(double x1, double y1, double x2, double y2); }
ProjectionRect { public static ProjectionRect intersect(ProjectionRect src1, ProjectionRect src2) { double x1 = Math.max(src1.getMinX(), src2.getMinX()); double y1 = Math.max(src1.getMinY(), src2.getMinY()); double x2 = Math.min(src1.getMaxX(), src2.getMaxX()); double y2 = Math.min(src1.getMaxY(), src2.getMaxY()); return builder().setX(x1).setY(y1).setWidth(x2 - x1).setHeight(y2 - y1).build(); } ProjectionRect();  ProjectionRect(ProjectionPoint corner1, ProjectionPoint corner2);  ProjectionRect(ProjectionPoint minimum, double width, double height);  ProjectionRect(double x1, double y1, double x2, double y2);  ProjectionRect(String spec); private  ProjectionRect(ProjectionRect.Builder builder); @Deprecated double getX(); @Deprecated double getY(); double getWidth(); double getHeight(); double getMinX(); double getMinY(); double getMaxX(); double getMaxY(); double getCenterX(); double getCenterY(); boolean isEmpty(); boolean intersects(ProjectionRect r); boolean intersects(double x, double y, double w, double h); static ProjectionRect intersect(ProjectionRect src1, ProjectionRect src2); boolean contains(ProjectionPoint point); boolean contains(ProjectionRect rect); ProjectionPoint getLowerRightPoint(); ProjectionPoint getUpperRightPoint(); ProjectionPoint getLowerLeftPoint(); ProjectionPoint getUpperLeftPoint(); ProjectionPoint getMinPoint(); ProjectionPoint getMaxPoint(); String toString(); String toString2(int ndec); String toStringSpec(); @Override boolean equals(Object o); @Override int hashCode(); boolean nearlyEquals(ProjectionRect other); boolean nearlyEquals(ProjectionRect other, double maxRelDiff); ProjectionRect.Builder toBuilder(); static Builder builder(); static Builder builder(double x1, double y1, double x2, double y2);  }