intersections method

List<Vector2> intersections(
  1. LineSegment line
)

Returns all intersections between this rectangle's edges and the given line segment.

Implementation

List<Vector2> intersections(LineSegment line) {
  final intersectionPoints = <Vector2>[];
  for (final edge in edges) {
    for (final intersection in edge.intersections(line)) {
      if (!intersectionPoints.contains(intersection)) {
        intersectionPoints.add(intersection);
      }
    }
  }
  return intersectionPoints;
}