Skip to content

Commit f3d249c

Browse files
authored
Merge pull request #15 from FugroRoames/extra-tests-05
Extra tests 05
2 parents e418cae + 38de650 commit f3d249c

File tree

2 files changed

+56
-8
lines changed

2 files changed

+56
-8
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ language: julia
33
os:
44
- linux
55
- osx
6+
branches:
7+
only:
8+
- master
69
julia:
710
- 0.5
811
- nightly

test/affine.jl

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,62 @@ CoordinateTransformations.transform_deriv(::SquareMe, x0) = diagm(2*x0)
66

77

88
@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
918

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 (A2A1)(x) == M2*(M1*x + v1) + v2
31+
@test (A2A1)(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
1743

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
1952

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 (LL)(x) == (M*M)*x
64+
end
2065

2166
@testset "Translation" begin
2267
x = SVector(1.0, 2.0)

0 commit comments

Comments
 (0)