|
1 | 1 | @testset "Perspective transformation" begin
|
2 | 2 | @test PerspectiveMap()([2.0, -1.0, 0.5]) ≈ [4.0, -2.0]
|
3 | 3 |
|
4 |
| - @test cameramap(2.0) ≈ LinearMap(UniformScaling(2.0)) ∘ PerspectiveMap() |
5 |
| - @test cameramap((1.1,2.2)) ≈ LinearMap([1.1 0; 0 2.2]) ∘ PerspectiveMap() |
6 |
| - @test cameramap(1.1, (3.3,4.4)) ≈ Translation([-3.3,-4.4]) ∘ LinearMap(UniformScaling(1.1)) ∘ PerspectiveMap() |
7 |
| - @test cameramap((1.1,2.2), (3.3,4.4)) ≈ Translation([-3.3,-4.4]) ∘ LinearMap([1.1 0; 0 2.2]) ∘ PerspectiveMap() |
| 4 | + if VERSION > v"0.6-" |
| 5 | + @test cameramap(2.0) ≈ LinearMap(UniformScaling(2.0)) ∘ PerspectiveMap() |
| 6 | + @test cameramap((1.1,2.2)) ≈ LinearMap([1.1 0; 0 2.2]) ∘ PerspectiveMap() |
| 7 | + @test cameramap(1.1, (3.3,4.4)) ≈ Translation([-3.3,-4.4]) ∘ LinearMap(UniformScaling(1.1)) ∘ PerspectiveMap() |
| 8 | + @test cameramap((1.1,2.2), (3.3,4.4)) ≈ Translation([-3.3,-4.4]) ∘ LinearMap([1.1 0; 0 2.2]) ∘ PerspectiveMap() |
| 9 | + else |
| 10 | + # `isapprox` for `UniformScaling` not defined. Just put a few points through and |
| 11 | + # test that we get the same results |
| 12 | + points = [[1.0,1.0,1.0], [-1.0,1.0,1.0], [-1.0,-1.0,1.0], [1.0,-1.0,1.0]] |
| 13 | + |
| 14 | + trans1 = cameramap(2.0) |
| 15 | + trans2 = LinearMap(UniformScaling(2.0)) ∘ PerspectiveMap() |
| 16 | + @test all(isapprox.(trans1.(points), trans2.(points))) |
| 17 | + |
| 18 | + trans1 = cameramap((1.1,2.2)) |
| 19 | + trans2 = LinearMap([1.1 0; 0 2.2]) ∘ PerspectiveMap() |
| 20 | + @test all(isapprox.(trans1.(points), trans2.(points))) |
| 21 | + |
| 22 | + trans1 = cameramap(1.1, (3.3,4.4)) |
| 23 | + trans2 = Translation([-3.3,-4.4]) ∘ LinearMap(UniformScaling(1.1)) ∘ PerspectiveMap() |
| 24 | + @test all(isapprox.(trans1.(points), trans2.(points))) |
| 25 | + |
| 26 | + trans1 = cameramap((1.1,2.2), (3.3,4.4)) |
| 27 | + trans2 = Translation([-3.3,-4.4]) ∘ LinearMap([1.1 0; 0 2.2]) ∘ PerspectiveMap() |
| 28 | + @test all(isapprox.(trans1.(points), trans2.(points))) |
| 29 | + |
| 30 | + end |
8 | 31 | end
|
0 commit comments