/** * Return true iff the projection of loop onto line (v0, v1) is completely * between v0 and v1. */ bool loop_is_valid(const MatrixFr& loop, const VectorF& v0, const VectorF& v1) { VectorF dir = v1 - v0; Float dir_sq_len = dir.squaredNorm(); if (dir_sq_len == 0.0) { throw RuntimeError("Zero edge encountered."); } VectorF proj = (loop.rowwise() - v0.transpose()) * dir / dir_sq_len; return ((proj.array() > 0.0).all() && (proj.array() < 1.0).all()); }