private List <Point> points() //n1からn2への折れ線の中間点 { List <Point> ps = new List <Point>(); Point p1 = n1.getP(); //始点 ps.Add(p1); if (n2 == null) { ps.Add(p); return(ps); } Point p1n = n1.getNP(); Point p2 = n2.getP(); Point p2n = n2.getNP(); Point pm = mid(p1, p2); if (n1.pos == n2.pos) { if (n1.pos == 1 || n1.pos == 3) // N->N || S->S { int y = (n1.pos == 1 ? Math.Min(p1n.Y, p2n.Y) : Math.Max(p1n.Y, p2n.Y)); ps.Add(new Point(p1.X, y)); ps.Add(new Point(p2.X, y)); } else { // E->E || W->W int x = (n1.pos == 2 ? Math.Max(p1n.X, p2n.X) : Math.Min(p1n.X, p2n.X)); ps.Add(new Point(x, p1.Y)); ps.Add(new Point(x, p2.Y)); } } else if ((n1.pos == 1 && n2.pos == 3) || (n1.pos == 3 && n2.pos == 1)) // N->S || S->N { bool b = (n1.pos == 1 ? p1n.Y > p2n.Y : p1n.Y < p2n.Y); if (b) { ps.Add(new Point(p1.X, pm.Y)); ps.Add(new Point(p2.X, pm.Y)); } else { ps.Add(new Point(p1.X, p1n.Y)); ps.Add(new Point(pm.X, p1n.Y)); ps.Add(new Point(pm.X, p2n.Y)); ps.Add(new Point(p2.X, p2n.Y)); } } else if ((n1.pos == 2 && n2.pos == 4) || (n1.pos == 4 && n2.pos == 2)) // E->W || W->E { bool b = (n1.pos == 2 ? p1n.X <p2n.X : p1n.X> p2n.X); if (b) { ps.Add(new Point(pm.X, p1.Y)); ps.Add(new Point(pm.X, p2.Y)); } else { ps.Add(new Point(p1n.X, p1.Y)); ps.Add(new Point(p1n.X, pm.Y)); ps.Add(new Point(p2n.X, pm.Y)); ps.Add(new Point(p2n.X, p2.Y)); } } else if (n1.pos == 1 || n1.pos == 3) // N->E, N->W, S->E, S->W { bool b1 = (n1.pos == 1 ? p1.Y > p2.Y : p1.Y < p2.Y); bool b2 = (n2.pos == 2 ? p1.X > p2.X : p1.X < p2.X); if (b1 && b2) { ps.Add(new Point(p1.X, p2.Y)); } else if (!b1 && b2) { ps.Add(new Point(p1.X, p1n.Y)); ps.Add(new Point(pm.X, p1n.Y)); ps.Add(new Point(pm.X, p2.Y)); } else { ps.Add(new Point(p1.X, p1n.Y)); ps.Add(new Point(p2n.X, p1n.Y)); ps.Add(new Point(p2n.X, p2.Y)); } } else // E->N, E->S, W->N, W->S { bool b1 = (n1.pos == 2 ? p1.X <p2.X : p1.X> p2.X); bool b2 = (n2.pos == 1 ? p1.Y <p2.Y : p1.Y> p2.Y); if (b1 && b2) { ps.Add(new Point(p2.X, p1.Y)); } else if (!b1 && b2) { ps.Add(new Point(p1n.X, p1.Y)); ps.Add(new Point(p1n.X, pm.Y)); ps.Add(new Point(p2.X, pm.Y)); } else { ps.Add(new Point(p1n.X, p1.Y)); ps.Add(new Point(p1n.X, p2n.Y)); ps.Add(new Point(p2.X, p2n.Y)); } } ps.Add(p2); return(ps); }