circumcentreStaticDD static method

Coordinate circumcentreStaticDD(
  1. Coordinate a,
  2. Coordinate b,
  3. Coordinate c
)

Computes the circumcentre of a triangle. The circumcentre is the centre of the circumcircle, the smallest circle which encloses the triangle. It is also the common intersection point of the perpendicular bisectors of the sides of the triangle, and is the only point which has equal distance to all three vertices of the triangle.

The circumcentre does not necessarily lie within the triangle. For example, the circumcentre of an obtuse isosceles triangle lies outside the triangle.

This method uses {@link DD} extended-precision arithmetic to provide more accurate results than {@link #circumcentre(Coordinate, Coordinate, Coordinate)}

@param a a vertex of the triangle @param b a vertex of the triangle @param c a vertex of the triangle @return the circumcentre of the triangle

Implementation

static Coordinate circumcentreStaticDD(
    Coordinate a, Coordinate b, Coordinate c) {
  DD ax = DD.valueOf(a.x).subtract(c.x);
  DD ay = DD.valueOf(a.y).subtract(c.y);
  DD bx = DD.valueOf(b.x).subtract(c.x);
  DD by = DD.valueOf(b.y).subtract(c.y);

  DD denom = DD.determinantDD(ax, ay, bx, by).multiply(2);
  DD asqr = ax.sqr().addDD(ay.sqr());
  DD bsqr = bx.sqr().addDD(by.sqr());
  DD numx = DD.determinantDD(ay, asqr, by, bsqr);
  DD numy = DD.determinantDD(ax, asqr, bx, bsqr);

  double ccx = DD.valueOf(c.x).subtractDD(numx.divideDD(denom)).doubleValue();
  double ccy = DD.valueOf(c.y).addDD(numy.divideDD(denom)).doubleValue();

  return new Coordinate(ccx, ccy);
}