Delaunay.Voronoi.CompareByYThenX C# (CSharp) Method

CompareByYThenX() public static method

public static CompareByYThenX ( Site s1, Site s2 ) : int
s1 Site
s2 Site
return int
		public 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;
		}

Same methods

Voronoi::CompareByYThenX ( Site s1, Vector2 s2 ) : int

Usage Example

Example #1
0
        /**
         * sort sites on y, then x, coord
         * also change each site's _siteIndex to match its new position in the list
         * so the _siteIndex can be used to identify the site for nearest-neighbor queries
         *
         * haha "also" - means more than one responsibility...
         *
         */
        public int CompareTo(System.Object obj)          // XXX: Really, really worried about this because it depends on how sorting works in AS3 impl - Julian
        {
            Site s2 = (Site)obj;

            int returnValue = Voronoi.CompareByYThenX(this, s2);

            // swap _siteIndex values if necessary to match new ordering:
            uint tempIndex;

            if (returnValue == -1)
            {
                if (this._siteIndex > s2._siteIndex)
                {
                    tempIndex       = this._siteIndex;
                    this._siteIndex = s2._siteIndex;
                    s2._siteIndex   = tempIndex;
                }
            }
            else if (returnValue == 1)
            {
                if (s2._siteIndex > this._siteIndex)
                {
                    tempIndex       = s2._siteIndex;
                    s2._siteIndex   = this._siteIndex;
                    this._siteIndex = tempIndex;
                }
            }

            return(returnValue);
        }
All Usage Examples Of Delaunay.Voronoi::CompareByYThenX