/**
 * Returns true if two lines intersect,
 * false otherwise.
 *
 * @author Ian Obermiller <ian.obermiller@mu.edu>
 * @date   01/30/2009
 *
 * thanks to Nick and 
 * http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
 */
public static boolean intersect(Line2D line0, Line2D line1)
{
	double l0x1 = line0.getX1();
	double l0y1 = line0.getY1();
	double l0x2 = line0.getX2();
	double l0y2 = line0.getY2();
	
	double l1x1 = line1.getX1();
	double l1y1 = line1.getY1();
	double l1x2 = line1.getX2();
	double l1y2 = line1.getY2();
	
	double denom = ((l0y2 - l0y1)*(l1x2 - l1x1)) -
		((l0x2 - l0x1)*(l1y2 - l1y1));

	double nume_a = ((l0x2 - l0x1)*(l1y1 - l0y1)) -
		((l0y2 - l0y1)*(l1x1 - l0x1));
	
	double nume_b = ((l1x2 - l1x1)*(l1y1 - l0y1)) -
		((l1y2 - l1y1)*(l1x1 - l0x1));


	if(denom == 0.0f)
	{
		if(nume_a == 0.0f && nume_b == 0.0f)
		{
			// Coincident
			return true;
		}
		// Parallel
		return false;
	}
	
	double ua = nume_a / denom;
	double ub = nume_b / denom;
	
	if(ua >= 0.0f && ua <= 1.0f && ub >= 0.0f && ub <= 1.0f)
	{
		// Get the intersection point.
		//double intersectionX = bX + ua*(eX - bX);
		//double intersectionY = bY + ua*(eY - bY);
		
		// Intersecting
		return true;
	}
	
	// Not intersecting
	return false;

}