public static int CompareByYThenX(Site s1, ICoord s2) { if (s1.Y < s2.Y) return -1; if (s1.Y > s2.Y) return 1; if (s1.X < s2.X) return -1; if (s1.X > s2.X) return 1; return 0; }
public static int CompareByYThenX(Site s1, ICoord s2) { if (s1.Y < s2.Y) { return(-1); } if (s1.Y > s2.Y) { return(1); } if (s1.X < s2.X) { return(-1); } if (s1.X > s2.X) { return(1); } return(0); }
public float Distance(ICoord p) { return(Vector2.Distance(p.Coord, Coord)); }
private List <Edge> ReorderEdges(List <Edge> origEdges, Type criterion) { var n = origEdges.Count; var done = Enumerable.Repeat(false, n).ToArray(); var nDone = 0; var newEdges = new List <Edge>(); var i = 0; var edge = origEdges[i]; newEdges.Add(edge); EdgeOrientations.Add(LR.Left); ICoord firstPoint = (criterion == typeof(Vertex) ? (ICoord)edge.LeftVertex : edge.LeftSite); ICoord lastPoint = (criterion == typeof(Vertex) ? (ICoord)edge.RightVertex : edge.RightSite); if (firstPoint == Vertex.VertexAtInfinity || lastPoint == Vertex.VertexAtInfinity) { return(new List <Edge>()); } done[i] = true; ++nDone; var loopCount = 0; while (nDone < n) { for (i = 1; i < n; i++) { if (done[i]) { continue; } edge = origEdges[i]; ICoord leftPoint = (criterion == typeof(Vertex) ? (ICoord)edge.LeftVertex : edge.LeftSite); ICoord rightPoint = (criterion == typeof(Vertex) ? (ICoord)edge.RightVertex : edge.RightSite); if (leftPoint == Vertex.VertexAtInfinity || rightPoint == Vertex.VertexAtInfinity) { return(new List <Edge>()); } if (leftPoint == lastPoint) { lastPoint = rightPoint; EdgeOrientations.Add(LR.Left); newEdges.Add(edge); done[i] = true; } else if (rightPoint == firstPoint) { firstPoint = leftPoint; EdgeOrientations.Add(LR.Left); newEdges.Insert(0, edge); done[i] = true; } else if (leftPoint == firstPoint) { firstPoint = rightPoint; EdgeOrientations.Insert(0, LR.Right); newEdges.Insert(0, edge); done[i] = true; } else if (rightPoint == lastPoint) { lastPoint = leftPoint; EdgeOrientations.Add(LR.Right); newEdges.Add(edge); done[i] = true; } if (done[i]) { ++nDone; } } loopCount++; if (loopCount > 1000) { break; } } return(newEdges); }