perpendicularBisector static method

HCoordinate perpendicularBisector(
  1. Coordinate a,
  2. Coordinate b
)

Computes the line which is the perpendicular bisector of the line segment a-b.

@param a a point @param b another point @return the perpendicular bisector, as an HCoordinate

Implementation

static HCoordinate perpendicularBisector(Coordinate a, Coordinate b) {
  // returns the perpendicular bisector of the line segment ab
  double dx = b.x - a.x;
  double dy = b.y - a.y;
  HCoordinate l1 = new HCoordinate.xyw(a.x + dx / 2.0, a.y + dy / 2.0, 1.0);
  HCoordinate l2 =
      new HCoordinate.xyw(a.x - dy + dx / 2.0, a.y + dx + dy / 2.0, 1.0);
  return new HCoordinate.from2Hc(l1, l2);
}