angle method

double angle()

Computes the angle that the vector defined by this segment makes with the X-axis. The angle will be in the range -PI, PI radians.

@return the angle this segment makes with the X-axis (in radians)

Implementation

double angle() {
  return math.atan2(p1.y - p0.y, p1.x - p0.x);
}