Voronoi diagram/J/Delaunay triangulation: Difference between revisions

m
Bug in convex_hull repaired. Occurred when more than 1 point have smallest y value.
m (Bug in convex_hull repaired. Occurred when more than 1 point have smallest y value.)
Line 137:
crossproduct=: 1 |. ([ * 1 |. ]) - ] * 1 |. [ NB. j forum
wind=: {:@:crossproduct&(,&0) NB. positive if CCL
smallest_by_coordinate=: 4 : '(#~ (= <./)@:(x&{"1)) y'
 
convex_hull=: 3 : 0 NB. Graham Scan y are the points
y=. ~. y NB. Implements Robert Sedgewick pseudo-code
N=. # y
start=. <, > smallest_by_coordinate&.>/ 0 ; 1 ; y
if. start -.@:e. y do. start=. start ,@:(=&({:"1) # ]) y end.
y=. y -. start
y=. y ([ /: angle@:-"1) start
Anonymous user