|
25 | 25 |
|
26 | 26 | let # test rotations
|
27 | 27 | qx = qrotation([1,0,0], pi/4)
|
28 |
| - @test_approx_eq qx*qx qrotation([1,0,0], pi/2) |
29 |
| - @test_approx_eq qx^2 qrotation([1,0,0], pi/2) |
| 28 | + @test qx*qx ≈ qrotation([1,0,0], pi/2) |
| 29 | + @test qx^2 ≈ qrotation([1,0,0], pi/2) |
30 | 30 | theta = pi/8
|
31 | 31 | qx = qrotation([1,0,0], theta)
|
32 | 32 | c = cos(theta); s = sin(theta)
|
33 | 33 | Rx = [1 0 0; 0 c -s; 0 s c]
|
34 |
| - @test_approx_eq rotationmatrix(qx) Rx |
| 34 | + @test rotationmatrix(qx) ≈ Rx |
35 | 35 | theta = pi/6
|
36 | 36 | qy = qrotation([0,1,0], theta)
|
37 | 37 | c = cos(theta); s = sin(theta)
|
38 | 38 | Ry = [c 0 s; 0 1 0; -s 0 c]
|
39 |
| - @test_approx_eq rotationmatrix(qy) Ry |
| 39 | + @test rotationmatrix(qy) ≈ Ry |
40 | 40 | theta = 4pi/3
|
41 | 41 | qz = qrotation([0,0,1], theta)
|
42 | 42 | c = cos(theta); s = sin(theta)
|
43 | 43 | Rz = [c -s 0; s c 0; 0 0 1]
|
44 |
| - @test_approx_eq rotationmatrix(qz) Rz |
| 44 | + @test rotationmatrix(qz) ≈ Rz |
45 | 45 |
|
46 |
| - @test_approx_eq rotationmatrix(qx*qy*qz) Rx*Ry*Rz |
47 |
| - @test_approx_eq rotationmatrix(qy*qx*qz) Ry*Rx*Rz |
48 |
| - @test_approx_eq rotationmatrix(qz*qx*qy) Rz*Rx*Ry |
| 46 | + @test rotationmatrix(qx*qy*qz) ≈ Rx*Ry*Rz |
| 47 | + @test rotationmatrix(qy*qx*qz) ≈ Ry*Rx*Rz |
| 48 | + @test rotationmatrix(qz*qx*qy) ≈ Rz*Rx*Ry |
49 | 49 |
|
50 | 50 | a, b = qrotation([0,0,1], deg2rad(0)), qrotation([0,0,1], deg2rad(180))
|
51 |
| - @test_approx_eq slerp(a,b,0.0) a |
52 |
| - @test_approx_eq slerp(a,b,1.0) b |
53 |
| - @test_approx_eq slerp(a,b,0.5) qrotation([0,0,1], deg2rad(90)) |
54 |
| - |
55 |
| - @test_approx_eq angle(qrotation([1,0,0], 0)) 0 |
56 |
| - @test_approx_eq angle(qrotation([0,1,0], pi/4)) pi/4 |
57 |
| - @test_approx_eq angle(qrotation([0,0,1], pi/2)) pi/2 |
58 |
| - |
| 51 | + @test slerp(a,b,0.0) ≈ a |
| 52 | + @test slerp(a,b,1.0) ≈ b |
| 53 | + @test slerp(a,b,0.5) ≈ qrotation([0,0,1], deg2rad(90)) |
59 | 54 |
|
| 55 | + @test angle(qrotation([1,0,0], 0)) ≈ 0 |
| 56 | + @test angle(qrotation([0,1,0], pi/4)) ≈ pi/4 |
| 57 | + @test angle(qrotation([0,0,1], pi/2)) ≈ pi/2 |
60 | 58 |
|
61 | 59 | let # test numerical stability of angle
|
62 | 60 | ax = randn(3)
|
63 | 61 | for θ in [1e-9, π - 1e-9]
|
64 | 62 | q = qrotation(ax, θ)
|
65 |
| - @test_approx_eq angle(q) θ |
| 63 | + @test angle(q) ≈ θ |
66 | 64 | end
|
67 | 65 | end
|
68 | 66 | end
|
|
0 commit comments