computeOrientation static method

int computeOrientation(
  1. CoordinateSequence cs,
  2. int p1,
  3. int p2,
  4. int q,
)

Implementation

static int computeOrientation(CoordinateSequence cs, int p1, int p2, int q) {
  // travelling along p1->p2, turn counter clockwise to get to q return 1,
  // travelling along p1->p2, turn clockwise to get to q return -1,
  // p1, p2 and q are colinear return 0.
  double p1x = cs.getOrdinate(p1, 0);
  double p1y = cs.getOrdinate(p1, 1);
  double p2x = cs.getOrdinate(p2, 0);
  double p2y = cs.getOrdinate(p2, 1);
  double qx = cs.getOrdinate(q, 0);
  double qy = cs.getOrdinate(q, 1);
  double dx1 = p2x - p1x;
  double dy1 = p2y - p1y;
  double dx2 = qx - p2x;
  double dy2 = qy - p2y;
  return RobustDeterminant.signOfDet2x2(dx1, dy1, dx2, dy2);
}