intersections method

List<Vector2> intersections(
  1. LineSegment otherSegment
)

Implementation

List<Vector2> intersections(LineSegment otherSegment) {
  final result = toLine().intersections(otherSegment.toLine());
  if (result.isNotEmpty) {
    final intersection = result.first;
    if (containsPoint(intersection) && otherSegment.containsPoint(intersection)) {
      return result;
    }
  }

  return [];
}