Exemplo n.º 1
0
        public bool IsCollinear(WireSegment other, int stepSize)
        {
            Location[] locs    = { this.End0, this.End1, other.End0, other.End1 };
            int        xMin    = Math.Min(this.End0.X, other.End0.X);
            int        xMax    = Math.Max(this.End1.X, other.End1.X);
            int        yMin    = Math.Min(Math.Min(this.End0.Y, this.End1.Y), Math.Min(other.End0.Y, other.End1.Y));
            int        yMax    = Math.Max(Math.Max(this.End0.Y, this.End1.Y), Math.Max(other.End0.Y, other.End1.Y));
            bool       sortByX = xMax - xMin >= yMax - yMin;

            if (sortByX)
            {
                locs = locs.OrderBy(loc => loc.X).ToArray();
            }
            else
            {
                locs = locs.OrderBy(loc => loc.Y).ToArray();
            }
            double tolerate = 0.5 * stepSize;

            if (locs[1] != locs[0] && !IsBetween(locs[1], locs[0], locs[3], sortByX, tolerate))
            {
                return(false);
            }
            else if (locs[2] != locs[3] && !IsBetween(locs[2], locs[0], locs[3], sortByX, tolerate))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 2
0
 public void RemoveWire(WireSegment wire)
 {
     CheckWriteAccess();
     layout.wires.Remove(wire);
 }