-
Notifications
You must be signed in to change notification settings - Fork 464
Open
Labels
Description
The following unit test fails:
public void testCollinear() {
Coordinate p0 = new Coordinate(0, 100);
Coordinate p1 = new Coordinate(1, 102.1082);
Coordinate p2 = new Coordinate(3, 106.3246);
assertEquals(Orientation.COLLINEAR, Orientation.index(p0, p1, p2));
}I'm aware that this is due to floating point arithmetic, so would it be acceptable to add the following overload of Orientation.index:
/**
* Returns the orientation index of the direction of the point <code>q</code> relative to
* a directed infinite line specified by <code>p1-p2</code>.
* The index indicates whether the point lies to the {@link #LEFT} or {@link #RIGHT}
* of the line, or lies on it {@link #COLLINEAR}.
* The index also indicates the orientation of the triangle formed by the three points
* ( {@link #COUNTERCLOCKWISE}, {@link #CLOCKWISE}, or {@link #STRAIGHT} )
*
* @param p1 the origin point of the line vector
* @param p2 the final point of the line vector
* @param q the point to compute the direction to
* @param eps a threshold value for the determinat to be meaningful
*
* @return -1 ( {@link #CLOCKWISE} or {@link #RIGHT} ) if q is clockwise (right) from p1-p2;
* 1 ( {@link #COUNTERCLOCKWISE} or {@link #LEFT} ) if q is counter-clockwise (left) from p1-p2;
* 0 ( {@link #COLLINEAR} or {@link #STRAIGHT} ) if q is collinear with p1-p2
*/
public static int index(Coordinate p1, Coordinate p2, Coordinate q, double eps)Reactions are currently unavailable