Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ private static int compareBetween(Coordinate origin, Coordinate p, Coordinate e0
* @return true if vector P has angle greater than Q
*/
private static boolean isAngleGreater(Coordinate origin, Coordinate p, Coordinate q) {
int quadrantP = quadrant(origin, p);
int quadrantQ = quadrant(origin, q);
int quadrantP = Quadrant.quadrant(origin, p);
int quadrantQ = Quadrant.quadrant(origin, q);

/**
* If the vectors are in different quadrants,
Expand All @@ -170,8 +170,8 @@ private static boolean isAngleGreater(Coordinate origin, Coordinate p, Coordinat
* @return a negative integer, zero, or a positive integer as this vector P has angle less than, equal to, or greater than vector Q
*/
public static int compareAngle(Coordinate origin, Coordinate p, Coordinate q) {
int quadrantP = quadrant(origin, p);
int quadrantQ = quadrant(origin, q);
int quadrantP = Quadrant.quadrant(origin, p);
int quadrantQ = Quadrant.quadrant(origin, q);

/**
* If the vectors are in different quadrants,
Expand All @@ -190,11 +190,6 @@ public static int compareAngle(Coordinate origin, Coordinate p, Coordinate q) {
default: return 0;
}
}

private static int quadrant(Coordinate origin, Coordinate p) {
double dx = p.getX() - origin.getX();
double dy = p.getY() - origin.getY();
return Quadrant.quadrant(dx, dy);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public class Quadrant
* Returns the quadrant of a directed line segment (specified as x and y
* displacements, which cannot both be 0).
*
* If the segment coordinates are available it is more robust
* to use {@link #quadrant(Coordinate, Coordinate).
*
* @throws IllegalArgumentException if the displacements are both 0
*/
public static int quadrant(double dx, double dy)
Expand All @@ -57,8 +60,8 @@ public static int quadrant(double dx, double dy)
/**
* Returns the quadrant of a directed line segment from p0 to p1.
*
* Note: using this method is more robust than using {@link #quadrant(double, double)
* if that requires subtractions to compute vector components.
* This method is more robust than {@link #quadrant(double, double)
* if using that requires subtractions to compute vector components.
*
* @throws IllegalArgumentException if the points are equal
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ protected void init(Coordinate p0, Coordinate p1)
{
this.p0 = p0;
this.p1 = p1;
quadrant = Quadrant.quadrant(p0, p1);
dx = p1.x - p0.x;
dy = p1.y - p0.y;
quadrant = Quadrant.quadrant(dx, dy);
Assert.isTrue(! (dx == 0 && dy == 0), "EdgeEnd with identical endpoints found");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public DirectedEdge(Node from, Node to, Coordinate directionPt, boolean edgeDire
this.edgeDirection = edgeDirection;
p0 = from.getCoordinate();
p1 = directionPt;
quadrant = Quadrant.quadrant(p0, p1);
double dx = p1.x - p0.x;
double dy = p1.y - p0.y;
quadrant = Quadrant.quadrant(dx, dy);
angle = Math.atan2(dy, dx);
//Assert.isTrue(! (dx == 0 && dy == 0), "EdgeEnd with identical endpoints found");
}
Expand Down
Loading