geometry :: ClockWiseSort :: defaultinit
geometry $ ClockWiseSort :: 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
geometry :: ClockWiseSort :: 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 center
# 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