hasInside method

bool hasInside(
  1. LatLng point
)

Implementation

bool hasInside(LatLng point) {
  double x = point.latitude;
  double y = point.longitude;

  double x1 = c1.latitude;
  double y1 = c1.longitude;

  double x2 = c2.latitude;
  double y2 = c2.longitude;

  double x3 = c3.latitude;
  double y3 = c3.longitude;

  double d1 = (x - x1) * (y2 - y1) - (y - y1) * (x2 - x1);
  double d2 = (x - x2) * (y3 - y2) - (y - y2) * (x3 - x2);
  double d3 = (x - x3) * (y1 - y3) - (y - y3) * (x1 - x3);

  return (d1 < 0 && d2 < 0 && d3 < 0) || (d1 > 0 && d2 > 0 && d3 > 0);
}