@@ -6,17 +6,62 @@ CoordinateTransformations.transform_deriv(::SquareMe, x0) = diagm(2*x0)
6
6
7
7
8
8
@testset " Common Transformations" begin
9
+ @testset " AffineTransformation" begin
10
+ @testset " Simple" begin
11
+ M = [1 2 ; 3 4 ]
12
+ v = [- 1 , 1 ]
13
+ x = [1 ,0 ]
14
+ y = [0.0 ,1.0 ]
15
+ A = AffineTransformation (M,v)
16
+ @test A (x) == M* x + v
17
+ end
9
18
10
- @testset " Local Affine transformation" begin
11
- S = SquareMe ()
12
- x0 = [1 ,2 ,3 ]
13
- dx = 0.1 * [1 ,- 1 ,1 ]
14
- A = AffineTransformation (S, x0)
15
- @test isapprox (S (x0 + dx), A (x0 + dx), atol= 1.01 * vecnorm (dx))
16
- end
19
+ @testset " composition " begin
20
+ M1 = [1 2 ; 3 4 ]
21
+ v1 = [- 1 , 1 ]
22
+ A1 = AffineTransformation (M1,v1)
23
+ M2 = [0 1 ; 1 0 ]
24
+ v2 = [- 2 , 0 ]
25
+ A2 = AffineTransformation (M2,v2)
26
+ x = [1 ,0 ]
27
+ y = [0 ,1 ]
28
+ @test A1 (x) == M1* x + v1
29
+ @test A1 (y) == M1* y + v1
30
+ @test (A2∘ A1)(x) == M2* (M1* x + v1) + v2
31
+ @test (A2∘ A1)(y) == M2* (M1* y + v1) + v2
32
+ end
33
+
34
+ @testset " inverse" begin
35
+ M = [1.0 2.0 ; 3.0 4.0 ]
36
+ v = [- 1.0 , 1.0 ]
37
+ x = [1 ,0 ]
38
+ y = [0.0 ,1.0 ]
39
+ A = AffineTransformation (M,v)
40
+ @test inv (A)(A (x)) ≈ x
41
+ @test inv (A)(A (y)) ≈ y
42
+ end
17
43
18
- # TODO LinearTransformation and AffineTransformation
44
+ @testset " Affine approximation" begin
45
+ S = SquareMe ()
46
+ x0 = [1 ,2 ,3 ]
47
+ dx = 0.1 * [1 ,- 1 ,1 ]
48
+ A = AffineTransformation (S, x0)
49
+ @test isapprox (S (x0 + dx), A (x0 + dx), atol= maximum (2 * dx.^ 2 ))
50
+ end
51
+ end
19
52
53
+ @testset " LinearTransformation" begin
54
+ M = [1 2 ; 3 4 ]
55
+ x = [1 ,0 ]
56
+ y = [0 ,1 ]
57
+ L = LinearTransformation (M)
58
+ @test L (x) == M* x
59
+ @test inv (L)(x) == inv (M)* x
60
+ @test inv (L)(y) == inv (M)* y
61
+ @test inv (L)(L (x)) ≈ x
62
+ @test inv (L)(L (y)) ≈ y
63
+ @test (L∘ L)(x) == (M* M)* x
64
+ end
20
65
21
66
@testset " Translation" begin
22
67
x = SVector (1.0 , 2.0 )
0 commit comments