Example #1
0
  bool LineSegment::xasc(const LineSegment& bottom, const LineSegment& top) {
    // both horizontal
    if(bottom.isHorizontal() && top.isHorizontal())
      return bottom.getLeftEndPoint().x < top.getLeftEndPoint().x;
    // left is vertical
    if(bottom.isHorizontal())
      return bottom.getLeftEndPoint().x < top.getBottomEndPoint().x;
    // left.left, left.right, right.left colinear
    if(Point2D::colinear(bottom.getBottomEndPoint(),
			 bottom.getTopEndPoint(),
			 top.getBottomEndPoint()))
      return Point2D::leftTurn(bottom.getBottomEndPoint(),
			       bottom.getTopEndPoint(),
			       top.getTopEndPoint());
    // normal case
    return Point2D::leftTurn(bottom.getBottomEndPoint(),
			     bottom.getTopEndPoint(),
			     top.getBottomEndPoint());
  }