How about some distant gravitational analogy. Say, the measure of being peripheral for each point is sum of inverse square of distances to each point.
mean=: +/ % # $pts=. <.(]-"1 mean) ~.|:+/&>?&.>(<3 1000)$&.>20 80 'X Y'=: |:pts sqdist=: ((X -/ X)^2) + (Y -/ Y)^2 meas=: +/ %1+sqdist fillmat=: 4 : 'x(<"1(] -"1 <./)y)}(1+ (>./ - <./) y)$0' viewmat meas fillmat pts NB. galaxy with gravitation plot /:~meas NB. response curve NB. say, cut off is 3 viewmat (1 + meas < 2) fillmat pts NB. your perimeter > From: Devon McCormick <[email protected]> > > Members of the Forum - > > I'm stymied by what seems like a simple problem that goes something like > this: I have a set of points longer in one direction than the other, like > this: > > $pts=. <.(]-"1 mean) ~.|:+/&>?&.>(<3 1000)$&.>20 80 NB. mean=: +/%# > 913 2 > viewmat 1 bordFill pts > NB. where > bordFill=: 4 : '(1)(<"1 y-"1 x-~<./y)}0$~2$(>:+:x)+(>./y)-<./y' NB. x > border around integer point pairs y > > I want to identify points near the perimeter. One idea I had for doing this > is to use polar coordinates, > > pp=. c2p"1 pts NB. Polar points: length, angle > NB. Where: > p2c=: +. @ (r./) NB.* p2c: polar to cartesian (point pair) > c2p=: ({.,2p1&|@{:)@:(*. @ (j./)) NB.* c2p: cartesian to polar (point pair) > > I want to get a rough idea of the perimeter by dividing the angles into, > say, 32 even groups and selecting the 10 most distant points within each > "wedge". > > gv=. /:1{"1 pp NB. Order by angle > > I'm not sure why the following does not seem to work correctly: > > lens=. (<.32*gv%#gv) > farpps=. (<.32*gv%#gv) > $farpps=. > ;((10{.\:)&.>lens){&.>farpps NB. Points corresponding to 10 > longest lengths > 320 2 > > [The expression "<.32*gv%#gv" is supposed to map the grade vector to key > values 0-31.] > > If this worked correctly, I'd expect the following image to show a ring of > differently-colored points as a perimeter: > > viewmat (2) (<"1]1+farpps-"1 <./pts)}1 bordFill pts > > Instead, the coloring seems to apply only to the points furthest from the > center, which tend to be those on either side along the longer axis. > > Does this make sense? Can anyone see what I'm doing wrong or suggest > another method? > > Thanks, > > Devon > -- > Devon McCormick, CFA > ^me^ at acm. > org is my > preferred e-mail > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
