HCoordinate.from4c constructor

HCoordinate.from4c(
  1. Coordinate p1,
  2. Coordinate p2,
  3. Coordinate q1,
  4. Coordinate q2,
)

Implementation

HCoordinate.from4c(
    Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2) {
  // unrolled computation
  double px = p1.y - p2.y;
  double py = p2.x - p1.x;
  double pw = p1.x * p2.y - p2.x * p1.y;

  double qx = q1.y - q2.y;
  double qy = q2.x - q1.x;
  double qw = q1.x * q2.y - q2.x * q1.y;

  x = py * qw - qy * pw;
  y = qx * pw - px * qw;
  w = px * qy - qx * py;
}