test_angle_between_planes.praat 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # test_angle_between_planes
  2. # djmw 20041021, 20070820
  3. appendInfoLine: "test_angle_between_planes.praat"
  4. appendInfoLine: tab$, "200 times: angle=randomUniform(0.001,90), numberOfRows = randomInteger (10,1000)"
  5. for i to 200
  6. hoek = randomUniform (0.001, 90)
  7. nrow = randomInteger (10,1000)
  8. @test: hoek, nrow, 3
  9. endfor
  10. appendInfoLine: "test_angle_between_planes.praat OK"
  11. procedure test: degrees, nrow, ncol,
  12. idt1 = Create TableOfReal: "t", nrow, ncol
  13. Formula: "if col=1 then randomGauss(0,10) else self endif"
  14. Formula: "if col=2 then randomGauss(0,5) else self endif"
  15. Formula: "if col=3 then randomGauss(0,2.5) else self endif"
  16. # Centering is very important
  17. Centre columns
  18. c = To Configuration
  19. Rotate (pc)
  20. idt2 = To TableOfReal
  21. pc1 = To PCA
  22. selectObject: c
  23. # The rotation is in the pc-coordinates frame
  24. Rotate... 1 3 degrees
  25. idt3 = To TableOfReal
  26. pc2 = To PCA
  27. selectObject: pc1, pc2
  28. degrees_found = Get angle between pc1-pc2 planes
  29. assert abs(degrees-degrees_found) < 2e-6; 'nrow' 'degrees' 'degrees_found'
  30. # printline 'nrow' 'degrees' 'degrees_found'
  31. removeObject: idt1, idt2, idt3, pc1, pc2, c
  32. endproc