intersect method

  1. @override
List<Vector2> intersect(
  1. CircleComponent circle,
  2. PathComponent path, {
  3. Rect? overlappingRect,
})
override

Returns the intersection points of circle and the edges of all the polygons of path.

Implementation

@override
List<Vector2> intersect(
  CircleComponent circle,
  PathComponent path, {
  Rect? overlappingRect,
}) {
  final intersectionPoints = <Vector2>[];
  for (final line in path.possibleIntersectionVertices(overlappingRect)) {
    for (final intersection in circle.lineSegmentIntersections(line)) {
      if (!intersectionPoints.contains(intersection)) {
        intersectionPoints.add(intersection);
      }
    }
  }
  if (intersectionPoints.isEmpty) {
    return _enclosedCenter(
      circle,
      circle.absoluteCenter,
      path,
      _vertexOf(path),
    );
  }
  return intersectionPoints;
}