private static int Compare(Site s1, Site s2) { var returnValue = CompareByYThenX(s1, s2); int tmpIndex; if (returnValue == -1) { if (s1._siteIndex > s2._siteIndex) { tmpIndex = s1._siteIndex; s1._siteIndex = s2._siteIndex; s2._siteIndex = tmpIndex; } } if (returnValue == 1) { if (s2._siteIndex > s1._siteIndex) { tmpIndex = s2._siteIndex; s2._siteIndex = s1._siteIndex; s1._siteIndex = tmpIndex; } } return returnValue; }
public static double Dist(Vector vector, Site site) { if (vector.Dimension != 2) { return -1; } return Math.Pow(vector.X - site.X, 2) + Math.Pow(vector.Y - site.Y, 2); ; }
private static int CompareByYThenX(Site s1, Site 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; }