intersectionsWithLineSegment method
Returns the List of parameter values for intersections between this and
the line segment defined by lineStartPoint
and lineEndPoint
.
Implementation
List<double> intersectionsWithLineSegment(
Vector2 lineStartPoint, Vector2 lineEndPoint) {
final minPoint = Vector2.zero();
Vector2.min(lineStartPoint, lineEndPoint, minPoint);
final maxPoint = Vector2.zero();
Vector2.max(lineStartPoint, lineEndPoint, maxPoint);
final boundingBox = Aabb2.minMax(minPoint, maxPoint);
final roots = rootsAlongLine(points, lineStartPoint, lineEndPoint);
roots.retainWhere((t) {
final p = pointAt(t);
return pointIntersectsBoundingBoxApproximately(p, boundingBox);
});
final rootsSet = Set<double>.from(roots);
final uniqueRoots = rootsSet.toList();
return uniqueRoots;
}