コード例 #1
0
 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)));
 }
コード例 #2
0
            public LineBoxEnclosingPointsEnumerator(Box box, IBoundedLine leftLine, IBoundedLine rightLine)
            {
                this.box       = box;
                this.leftLine  = leftLine;
                this.rightLine = rightLine;

                y = box.Bottom;
            }
コード例 #3
0
        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;
        }
コード例 #4
0
 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);
 }