geometry :: PolygonSorter :: calc_center
Calculate the centergeometry :: PolygonSorter :: center=
Center of the polygon's pointsgeometry :: PolygonSorter :: defaultinit
geometry :: PolygonSorter :: with_center
init calculating the centergeometry $ PolygonSorter :: SELF
Type of this instance, automatically specialized in every classcore :: Comparator :: bubble_sort
Bubble-sortarray
between from
and to
indices
core :: Comparator :: build_heap
geometry :: PolygonSorter :: calc_center
Calculate the centergeometry :: PolygonSorter :: center=
Center of the polygon's pointscore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
geometry :: PolygonSorter :: defaultinit
core :: Object :: defaultinit
core :: Comparator :: defaultinit
core :: Comparator :: insertion_sort
Insertion-sortarray
between from
and to
indices
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Comparator :: merge_sort
Merge-sortarray
between from
and to
indices
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).core :: Comparator :: quick_sort
Quick-sortarray
between from
and to
indices
geometry :: PolygonSorter :: with_center
init calculating the centergeometry :: CounterClockWiseSort
Sort the vertices of a polygon in counter clockwise order
# 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