Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmoten committed Dec 14, 2017
1 parent 0bb151b commit d9a3669
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/github/davidmoten/rtree/geometry/Line.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.github.davidmoten.guavamini.Objects;
import com.github.davidmoten.guavamini.Optional;
import com.github.davidmoten.rtree.internal.Line2D;
import com.github.davidmoten.rtree.internal.Rectangle2D;
import com.github.davidmoten.rtree.internal.RectangleUtil;
import com.github.davidmoten.rtree.internal.util.ObjectsHelper;

/**
Expand Down Expand Up @@ -72,7 +72,7 @@ public Rectangle mbr() {

@Override
public boolean intersects(Rectangle r) {
return Rectangle2D.rectangleIntersectsLine(r.x1(), r.y1(), r.x2() - r.x1(), r.y2() - r.y1(),
return RectangleUtil.rectangleIntersectsLine(r.x1(), r.y1(), r.x2() - r.x1(), r.y2() - r.y1(),
x1, y1, x2, y2);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.github.davidmoten.rtree.internal;

public class Rectangle2D {
public final class RectangleUtil {

private RectangleUtil() {
// prevent instantiation
}

/**
* The bitmask that indicates that a point lies to the left of this
Expand Down Expand Up @@ -89,9 +93,10 @@ private static boolean pointOnSegment(double x, double y, double x1, double y1,
double y2) {
if (x < x1 || x > x2 || y < y1 || y > y2) {
return false;
} else {
double v = (y2 - y1) * (x - x1) - (x2 - x1) * (y - y1);
return Math.abs(v) < PRECISION;
}
double v = (y2 - y1) * (x - x1) - (x2 - x1) * (y - y1);
return Math.abs(v) < PRECISION;
}

private static int outcode(double rectX, double rectY, double rectWidth, double rectHeight,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.github.davidmoten.rtree.internal;

import org.junit.Test;

import com.github.davidmoten.junit.Asserts;

public class RectangleUtilTest {

@Test
public void isUtilityClass() {
Asserts.assertIsUtilityClass(RectangleUtil.class);
}

}

0 comments on commit d9a3669

Please sign in to comment.