isParallelTo method

bool isParallelTo(
  1. Line other
)

Check if this line is parallel to other

Two lines are parallel if they have the same slope, or both are vertical.

Implementation

bool isParallelTo(Line other) {
  final dx1 = b.x - a.x;
  final dy1 = b.y - a.y;
  final dx2 = other.b.x - other.a.x;
  final dy2 = other.b.y - other.a.y;
  // Cross product == 0 means parallel
  return (dx1 * dy2 - dy1 * dx2).abs() < 1e-10;
}