Guest User

Untitled

a guest
Oct 21st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. cotanSort :: [Point] -> [Point]
  2. cotanSort ps = initialPoint : sortBy cotanCompare remainingPoints
  3. where
  4. initialSorting = initialSort ps
  5. initialPoint = head initialSorting
  6. remainingPoints = tail initialSorting
  7. (pivotx,pivoty) = initialPoint
  8. cotanCompare (px,py) (qx,qy)
  9. | pCalc > qCalc = GT
  10. | pCalc < qCalc = LT
  11. | py < qy = GT
  12. | px > qx = GT
  13. | otherwise = EQ
  14. where
  15. pCalc = (py-pivoty)*(qx-pivotx)
  16. qCalc = (qy-pivoty)*(px-pivotx)
Add Comment
Please, Sign In to add comment