test_Polygon_simplify.praat 919 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # test_Polygon_simplify.praat
  2. printline test_Polygon_simplify
  3. for j to 10
  4. m = Create simple Matrix... ps 2 100 randomUniform (0,1)
  5. p1x = Get value in cell... 1 1
  6. p1y = Get value in cell... 2 1
  7. p2x = Get value in cell... 1 10
  8. p2y = Get value in cell... 2 10
  9. for i from 2 to 99
  10. if ( i mod 10) =0
  11. p1x = Get value in cell... 1 i
  12. p1y = Get value in cell... 2 i
  13. p2x = Get value in cell... 1 i+10
  14. p2y = Get value in cell... 2 i+10
  15. elsif ( i mod 10) >0
  16. # 9 points on the edge from p(i) to point(i+10)
  17. af = randomUniform (0,1)
  18. xn = p1x +af*(p2x-p1x)
  19. yn = p1y + af*(p2y-p1y)
  20. Set value... 1 i xn
  21. Set value... 2 i yn
  22. endif
  23. endfor
  24. p = To Polygon
  25. for k to 10
  26. select p
  27. p3 = Circular permutation... randomUniform (1, 100)
  28. p4 = Simplify
  29. np = Get number of points
  30. assert np = 11
  31. plus p3
  32. Remove
  33. endfor
  34. select m
  35. plus p
  36. Remove
  37. endfor
  38. printline test_Polygon_simplify OK