quadrant static method

int quadrant(
  1. double dx,
  2. double dy
)

Returns the quadrant of a directed line segment (specified as x and y displacements, which cannot both be 0).

@throws IllegalArgumentException if the displacements are both 0

Implementation

static int quadrant(double dx, double dy) {
  if (dx == 0.0 && dy == 0.0) {
    throw ArgumentError("Cannot compute the quadrant for point ( $dx, $dy )");
  }
  if (dx >= 0.0) {
    if (dy >= 0.0)
      return NE;
    else
      return SE;
  } else {
    if (dy >= 0.0)
      return NW;
    else
      return SW;
  }
}