angleBisector static method

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

Computes the point at which the bisector of the angle ABC cuts the segment AC.

@param a a vertex of the triangle @param b a vertex of the triangle @param c a vertex of the triangle @return the angle bisector cut point

Implementation

static Coordinate angleBisector(Coordinate a, Coordinate b, Coordinate c) {
  /**
   * Uses the fact that the lengths of the parts of the split segment are
   * proportional to the lengths of the adjacent triangle sides
   */
  double len0 = b.distance(a);
  double len2 = b.distance(c);
  double frac = len0 / (len0 + len2);
  double dx = c.x - a.x;
  double dy = c.y - a.y;

  Coordinate splitPt = new Coordinate(a.x + frac * dx, a.y + frac * dy);
  return splitPt;
}