Debian Codegraph @

dwtest/test_angle_between_planes.praat

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