isLinesOver static method

bool isLinesOver(
  1. Vector2 a,
  2. Vector2 b,
  3. Vector2 c,
  4. Vector2 d,
)

Straddle experiment Determine whether the line segment a~b and the line segment c~d https://www.rogoso.info/%E5%88%A4%E6%96%AD%E7%BA%BF%E6%AE%B5%E7%9B%B8%E4%BA%A4/

Implementation

static bool isLinesOver(Vector2 a, Vector2 b, Vector2 c, Vector2 d) {
  final ac = VectorVector(a, c);
  final ad = VectorVector(a, d);
  final bc = VectorVector(b, c);
  final bd = VectorVector(b, d);
  final ca = ac.negative;
  final cb = bc.negative;
  final da = ad.negative;
  final db = bd.negative;

  return vectorProduct(ac, ad) * vectorProduct(bc, bd) <= 0 &&
      vectorProduct(ca, cb) * vectorProduct(da, db) <= 0;
}