isPerpendicularTo method

bool isPerpendicularTo(
  1. Line other
)

Check if this line is perpendicular to other

Two lines are perpendicular if their dot product is zero.

Implementation

bool isPerpendicularTo(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;
  return (dx1 * dx2 + dy1 * dy2).abs() < 1e-10;
}