Example #1
0
        public bool Intersects(VectorLine v)
        {
            VectorLine L;
            Vector     hp = Vector.Zero;

            L = new VectorLine(LL, Vector.V(UR.x, LL.y), VectorLine.LineType.AB);
            if (VectorLine.intersect(v, L, ref hp))
            {
                return(true);
            }
            L = new VectorLine(Vector.V(UR.x, LL.y), UR, VectorLine.LineType.AB);
            if (VectorLine.intersect(v, L, ref hp))
            {
                return(true);
            }
            L = new VectorLine(UR, Vector.V(LL.x, UR.y), VectorLine.LineType.AB);
            if (VectorLine.intersect(v, L, ref hp))
            {
                return(true);
            }
            L = new VectorLine(Vector.V(LL.x, UR.y), LL, VectorLine.LineType.AB);
            if (VectorLine.intersect(v, L, ref hp))
            {
                return(true);
            }
            //if ((v.A.x >= LL.x) && (v.A.x <= UR.x) && (v.A.y >= LL.y) && (v.A.y <= UR.y)) return true;
            return(false);
        }
Example #2
0
            private void tracePath(int from, int to, List <VectorLine> lines, List <VectorPath> vp, VectorPath start, List <int> startl)
            {
                if (from == to)
                {
                    // On the final line
                    VectorPath ep = new VectorPath(start);
                    ep.addPoint(lines[to].B);
                    vp.Add(ep);
                    return;
                }

                // Check for intersections
                for (int i = 0; i < lines.Count; i++)
                {
                    if ((i != from) && (startl.IndexOf(i) < 0))
                    {
                        Vector ip = Vector.Zero;
                        if (VectorLine.intersect(lines[from], lines[i], ref ip))
                        {
                            // Lines intersect!
                            bool isavalidline = true;
                            if (isavalidline && (startl.Count > 1) && _VA.nonZero && _VA.inside(ip))
                            {
                                isavalidline = false;
                            }
                            if (isavalidline && _VB.nonZero && _VB.inside(ip))
                            {
                                isavalidline = false;
                            }
                            VectorLine nl = new VectorLine(start.list.Last(), ip, VectorLine.LineType.AB);
                            if (isavalidline && (startl.Count > 1) && _VA.nonZero && _VA.Intersects(nl))
                            {
                                isavalidline = false;
                            }
                            if (isavalidline && _VB.nonZero && _VB.Intersects(nl))
                            {
                                isavalidline = false;
                            }
                            if (isavalidline)
                            {
                                VectorPath ep      = new VectorPath(start);
                                List <int> startlx = new List <int>(startl);
                                startlx.Add(i);
                                ep.addPoint(ip);
                                tracePath(i, to, lines, vp, ep, startlx);
                            }
                        }
                    }
                }
            }