Exemplo n.º 1
0
 private bool IntersectsCoincidental(OrthoLine line, out Point intersection)
 {
     if ((this.Start <= line.Start && line.Start <= this.End) || (this.Start >= line.Start && line.Start >= this.End))
     {
         intersection = this.IsHorizontal ? new Point(line.Start, this.Offset) : new Point(this.Offset, line.Start);
         return(true);
     }
     else if ((this.Start <= line.End && line.End <= this.End) || (this.Start >= line.End && line.End >= this.End))
     {
         intersection = this.IsHorizontal ? new Point(line.End, this.Offset) : new Point(this.Offset, line.End);
         return(true);
     }
     else if ((line.Start <= this.Start && this.Start <= line.End) || (line.Start >= this.Start && this.Start >= line.End))
     {
         intersection = this.IsHorizontal ? new Point(this.Start, this.Offset) : new Point(this.Offset, this.Start);
         return(true);
     }
     else if ((line.Start <= this.End && this.End <= line.End) || (line.Start >= this.End && this.End >= line.End))
     {
         intersection = this.IsHorizontal ? new Point(this.End, this.Offset) : new Point(this.Offset, this.End);
         return(true);
     }
     else
     {
         intersection = Point.Origin;
         return(false);
     }
 }
Exemplo n.º 2
0
        public bool Intersects(OrthoLine line, out Point intersection)
        {
            if (((this.IsHorizontal && line.IsHorizontal) || (this.IsVertical && line.IsVertical)))
            {
                if (this.Offset == line.Offset)
                {
                    // Lines are coincidental horizontally
                    return(this.IntersectsCoincidental(line, out intersection));
                }
                else
                {
                    intersection = Point.Origin;
                    return(false);
                }
            }
            else if (IsBetween(this.Start, this.End, line.Offset) && IsBetween(line.Start, line.End, this.Offset))
            {
                // Lines intersect
                if (this.IsHorizontal)
                {
                    intersection = new Point(line.Offset, this.Offset);
                }
                else
                {
                    intersection = new Point(this.Offset, line.Offset);
                }

                return(true);
            }
            else
            {
                // Parallel lines can't intersect
                intersection = Point.Origin;
                return(false);
            }
        }