Property definitions

geometry $ ClockWiseSort :: defaultinit
# Sort the vertices of a polygon in clockwise order
private class ClockWiseSort
	super PolygonSorter

	redef fun compare(a,b) do
		if a.x == b.x and a.y == b.y then return 0
		if a.x - center.x >= 0.0 and b.x - center.x < 0.0 then return 1
		if a.x - center.x < 0.0 and b.x - center.x >= 0.0 then return -1
		if a.x - center.x == 0.0 and b.x - center.x == 0 then
			if a.y - center.y >= 0.0 or b.y - center.y >= 0.0 then
				if a.y > b.y then return 1
				return -1
			end
			if b.y > a.y then return 1
			return -1
		end

		var det = (a.x - center.x) * (b.y - center.y) - (b.x - center.x) * (a.y - center.y)
		if det > 0.0 then return -1
		if det < 0.0 then return 1

		var d1 = (a.x - center.x) * (a.x - center.x) + (a.y - center.y) * (a.y - center.y)
		var d2 = (b.x - center.x) * (b.x - center.x) + (b.y - center.y) * (b.y - center.y)
		if d1 > d2 then return 1
		return -1
	end
end
lib/geometry/polygon.nit:364,1--390,3