[Jprogramming] convex quadrilateral chances?

Raul Miller rauldmiller at gmail.com
Wed Dec 10 06:51:29 HKT 2008


I am playing around with a problem, and I feel like I am missing
a couple basic concepts, so I was wondering if anyone had
any quick suggestions:

If I have code which finds a shortest cycle which visits all points in a set:

loopdist=: +/@:(+/&.:*:"1)@:(- 1&|.)"2
sortloops=:{.@(/: loopdist)@({~  (!@<: A.&i. ])@#)"2

And I use this to generate some random quadrilaterals
(with coordinates of each chosen arbitrarily from some
linearly distributed range):

data=: sortloops (?.20 4 2$1000)+"1"_1(1000*4 5 #:i.20)

What are the odds that any given quadrilateral is
not concave?

require'plot'
plot j./"1 (,{.)"2 data

Thanks,

-- 
Raul


More information about the Programming mailing list