static IEnumerable <IntVector2> GetLineBoxEnclosingPoints(Box box, IBoundedLine leftLine, IBoundedLine rightLine) { return(from y in ListUtil.FromTo(box.Bottom, box.Top - 1) let rightX = (int)rightLine.X(y) from x in ListUtil.FromTo((int)leftLine.X(y), rightX) select(new IntVector2(x, y))); }
public LineBoxEnclosingPointsEnumerator(Box box, IBoundedLine leftLine, IBoundedLine rightLine) { this.box = box; this.leftLine = leftLine; this.rightLine = rightLine; y = box.Bottom; }
public static Maybe<DoubleVector2> IntersectBounded(IBoundedLine first, IBoundedLine second) { var unbounded = Intersect(first, second); if (unbounded.IsNothing) return unbounded; var intersection = unbounded.FromJust; if (!IsIntersectionWithinBounds(first, intersection) || !IsIntersectionWithinBounds(second, intersection)) return MaybeUtil.Nothing<DoubleVector2>(); return unbounded; }
private static bool IsIntersectionWithinBounds(IBoundedLine second, DoubleVector2 intersection) { return (second.LeftX < intersection.X && intersection.X < second.RightX) || (second.BottomY < intersection.Y && intersection.Y < second.TopY); }