Property definitions

geometry $ PolygonSorter :: defaultinit
# Sorter for polygon vertices
private abstract class PolygonSorter
	super Comparator

	redef type COMPARED: Point[Float]

	# Center of the polygon's points
	var center: COMPARED

	# init calculating the center
	init with_center(pts : Array[Array[Float]]) do
		init(calc_center(pts))
	end

	# Calculate the center
	fun calc_center(pts : Array[Array[Float]]): COMPARED do
		var sumx = 0.0
		var sumy = 0.0
		for ap in pts do
			sumx += ap[0]
			sumy += ap[1]
		end
		return new Point[Float](sumx / pts.length.to_f, sumy / pts.length.to_f)
	end
end
lib/geometry/polygon.nit:308,1--332,3