예제 #1
0
    public PointF?Intersect(LineSegment other)
    {
        var p = line.Intersect(other.line);

        if (p == null)
        {
            return(null);
        }
        if (bindingRectangle.Contains(p.Value) &&
            other.bindingRectangle.Contains(p.Value))
        {
            return(p);
        }
        return(null);
    }
예제 #2
0
    public PointF?Intersect(LineEquation other)
    {
        if (isVertical && other.isVertical)
        {
            return(null);
        }
        if (a == other.a)
        {
            return(null);
        }
        if (isVertical)
        {
            return(other.Intersect(xConstForVertical));
        }
        if (other.isVertical)
        {
            return(Intersect(other.xConstForVertical));
        }
        // both have slopes and are not parallel
        var x = (b - other.b) / (other.a - a);

        return(Intersect(x));
    }
예제 #3
0
        public (bool Intersects, Vector Location) FindIntersect(LineEquation l)
        {
            var intersect = Line.Intersect(l);

            return(PointWithinBox(intersect), intersect);
        }