private boolean GetOverlapSegment(IntPoint pt1a, IntPoint pt1b, IntPoint pt2a, IntPoint pt2b, final AtomicReference<IntPoint> pt1, final AtomicReference<IntPoint> pt2) {
		// precondition: segments are colinear.
		if(Math.abs(pt1a.x - pt1b.x) > Math.abs(pt1a.y - pt1b.y)) {
			if(pt1a.x > pt1b.x) {
				IntPoint t = pt1a;
				pt1a = pt1b;
				pt1b = t;
			}
			if(pt2a.x > pt2b.x) {
				IntPoint t = pt2a;
				pt2a = pt2b;
				pt2b = t;
			}
			if(pt1a.x > pt2a.x)
				pt1.set(pt1a);
			else
				pt1.set(pt2a);
			if(pt1b.x < pt2b.x)
				pt2.set(pt1b);
			else
				pt2.set(pt2b);
			return pt1.get().x < pt2.get().x;
		} else {
			if(pt1a.y < pt1b.y) {
				IntPoint t = pt1a;
				pt1a = pt1b;
				pt1b = t;
			}
			if(pt2a.y < pt2b.y) {
				IntPoint t = pt2a;
				pt2a = pt2b;
				pt2b = t;
			}
			if(pt1a.y < pt2a.y)
				pt1.set(pt1a);
			else
				pt1.set(pt2a);
			if(pt1b.y > pt2b.y)
				pt2.set(pt1b);
			else
				pt2.set(pt2b);
			return pt1.get().y > pt2.get().y;
		}
	}