java.lang.Object computational.geometry.BasicTests
public class BasicTests
Method Summary | |
---|---|
static boolean |
between(Point s0,
Point s1,
Point p)
Tests if a point lies on a line segment. |
static boolean |
between(Segment s,
Point p)
Tests if a point lies on a line segment. |
static boolean |
collinear(Point p0,
Point p1,
Point p2)
Tests collinearity between three points. |
static int |
crossProduct(int x0,
int y0,
int x1,
int y1)
Computes the cross-product (i.e. |
static int |
crossProduct(Point p0,
Point p1)
Computes the cross-product of two vectors. |
static boolean |
intersect(Segment s,
Segment t)
Tests if two segments intersect. |
static boolean |
intersectProperly(Segment s,
Segment t)
Tests if two segments intersect properly. |
static boolean |
sameSide(Point p0,
Point p1,
Segment s)
Tests whether two points are on the same side of the half-plane defined by a segment. |
static int |
turns(Point p0,
Point p1,
Point p2)
Determines whether two consecutive line segments form a left turn, a right turn or they are collinear. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean between(Point s0, Point s1, Point p)
s0
- the segment's first endpoint.s1
- the segment's second endpoint.p
- the point.
public static boolean between(Segment s, Point p)
s
- the segment.p
- the point.
public static boolean collinear(Point p0, Point p1, Point p2)
p0
- the first point.p1
- the second point.p2
- the third point.
public static int crossProduct(int x0, int y0, int x1, int y1)
Warning: the X-axis is directed left to right, whether the Y-axis is directed top-down, contrary to the usual geometric conventions. To overcome this problem, we obtain the vectorial product of two points (x0,y0) and (x1,y1) by computing the determinant of the matrix:
i | j | k |
x0 | -y0 | 0 |
x1 | -y1 | 0 |
x0
- the first vector's x-coordinatey0
- the first vector's y-coordinatex1
- the second vector's x-coordinatey1
- the second vector's y-coordinate
public static int crossProduct(Point p0, Point p1)
p0
- the first vector (represented as a Point)p1
- the second vector (represented as a Point)
crossProduct(int,int,int,int)
public static boolean intersect(Segment s, Segment t)
s
- the first segment.t
- the second segment.
public static boolean intersectProperly(Segment s, Segment t)
s
- the first segment.t
- the second segment.
public static boolean sameSide(Point p0, Point p1, Segment s)
p0
- the first point.p1
- the second point.s
- the segment defining the half-plane.public static int turns(Point p0, Point p1, Point p2)
p0
- the first segment's first endpoint.p1
- the common endpoint between the two segments.p2
- the second segment's second endpoint.
Turn