@@ -9,28 +9,28 @@ Construct the `Translation` transformation for translating Cartesian points by
9
9
an offset `v = (dx, dy, ...)`
10
10
"""
11
11
struct Translation{V} <: AbstractAffineMap
12
- v :: V
12
+ translation :: V
13
13
end
14
14
Translation (x:: Tuple ) = Translation (SVector (x))
15
15
Translation (x,y) = Translation (SVector (x,y))
16
16
Translation (x,y,z) = Translation (SVector (x,y,z))
17
- Base. show (io:: IO , trans:: Translation ) = print (io, " Translation$((trans. v ... ,)) " )
17
+ Base. show (io:: IO , trans:: Translation ) = print (io, " Translation$((trans. translation ... ,)) " )
18
18
19
19
function (trans:: Translation{V} )(x) where {V}
20
- x + trans. v
20
+ x + trans. translation
21
21
end
22
22
23
- Base. inv (trans:: Translation ) = Translation (- trans. v )
23
+ Base. inv (trans:: Translation ) = Translation (- trans. translation )
24
24
25
25
function compose (trans1:: Translation , trans2:: Translation )
26
- Translation (trans1. v + trans2. v )
26
+ Translation (trans1. translation + trans2. translation )
27
27
end
28
28
29
29
transform_deriv (trans:: Translation , x) = I
30
30
transform_deriv_params (trans:: Translation , x) = I
31
31
32
32
function Base. isapprox (t1:: Translation , t2:: Translation ; kwargs... )
33
- isapprox (t1. v , t2. v ; kwargs... )
33
+ isapprox (t1. translation , t2. translation ; kwargs... )
34
34
end
35
35
36
36
@@ -42,43 +42,43 @@ A general linear transformation, constructed using `LinearMap(M)`
42
42
for any matrix-like object `M`.
43
43
"""
44
44
struct LinearMap{M} <: AbstractAffineMap
45
- m :: M
45
+ linear :: M
46
46
end
47
- Base. show (io:: IO , trans:: LinearMap ) = print (io, " LinearMap($(trans. m ) )" ) # TODO make this output more petite
47
+ Base. show (io:: IO , trans:: LinearMap ) = print (io, " LinearMap($(trans. linear ) )" ) # TODO make this output more petite
48
48
49
49
function (trans:: LinearMap{M} )(x) where {M}
50
- trans. m * x
50
+ trans. linear * x
51
51
end
52
52
53
- Base. inv (trans:: LinearMap ) = LinearMap (inv (trans. m ))
53
+ Base. inv (trans:: LinearMap ) = LinearMap (inv (trans. linear ))
54
54
55
- compose (t1:: LinearMap , t2:: LinearMap ) = LinearMap (t1. m * t2. m )
55
+ compose (t1:: LinearMap , t2:: LinearMap ) = LinearMap (t1. linear * t2. linear )
56
56
57
57
function Base. isapprox (t1:: LinearMap , t2:: LinearMap ; kwargs... )
58
- isapprox (t1. m , t2. m ; kwargs... )
58
+ isapprox (t1. linear , t2. linear ; kwargs... )
59
59
end
60
60
61
61
function Base. isapprox (t1:: LinearMap , t2:: Translation ; kwargs... )
62
- isapprox (vecnorm (t1. m ), 0 ; kwargs... ) &&
63
- isapprox (vecnorm (t2. v ),0 ; kwargs... )
62
+ isapprox (vecnorm (t1. linear ), 0 ; kwargs... ) &&
63
+ isapprox (vecnorm (t2. translation ),0 ; kwargs... )
64
64
end
65
65
66
66
function Base. isapprox (t1:: Translation , t2:: LinearMap ; kwargs... )
67
- isapprox (vecnorm (t1. v ), 0 ; kwargs... ) &&
68
- isapprox (vecnorm (t2. m ),0 ; kwargs... )
67
+ isapprox (vecnorm (t1. translation ), 0 ; kwargs... ) &&
68
+ isapprox (vecnorm (t2. linear ),0 ; kwargs... )
69
69
end
70
70
71
71
function Base.:(== )(t1:: LinearMap , t2:: Translation )
72
- vecnorm (t1. m ) == 0 &&
73
- 0 == vecnorm (t2. v )
72
+ vecnorm (t1. linear ) == 0 &&
73
+ 0 == vecnorm (t2. translation )
74
74
end
75
75
76
76
function Base.:(== )(t1:: Translation , t2:: LinearMap )
77
- vecnorm (t1. v ) == 0 &&
78
- vecnorm (t2. m ) == 0
77
+ vecnorm (t1. translation ) == 0 &&
78
+ vecnorm (t2. linear ) == 0
79
79
end
80
80
81
- transform_deriv (trans:: LinearMap , x) = trans. m
81
+ transform_deriv (trans:: LinearMap , x) = trans. linear
82
82
# TODO transform_deriv_params
83
83
84
84
"""
@@ -96,12 +96,12 @@ converted into an affine approximation by linearizing about a point `x` using
96
96
For transformations which are already affine, `x` may be omitted.
97
97
"""
98
98
struct AffineMap{M, V} <: AbstractAffineMap
99
- m :: M
100
- v :: V
99
+ linear :: M
100
+ translation :: V
101
101
end
102
102
103
103
function (trans:: AffineMap{M, V} )(x) where {M, V}
104
- trans. m * x + trans. v
104
+ trans. linear * x + trans. translation
105
105
end
106
106
107
107
# Note: the expression `Tx - dT*Tx` will have large cancellation error for
@@ -121,88 +121,88 @@ function AffineMap(trans::Transformation, x0)
121
121
AffineMap (dT, Tx - dT* x0)
122
122
end
123
123
124
- Base. show (io:: IO , trans:: AffineMap ) = print (io, " AffineMap($(trans. m ) , $(trans. v ) )" ) # TODO make this output more petite
124
+ Base. show (io:: IO , trans:: AffineMap ) = print (io, " AffineMap($(trans. linear ) , $(trans. translation ) )" ) # TODO make this output more petite
125
125
126
126
function compose (t1:: Translation , t2:: LinearMap )
127
- AffineMap (t2. m , t1. v )
127
+ AffineMap (t2. linear , t1. translation )
128
128
end
129
129
130
130
function compose (t1:: LinearMap , t2:: Translation )
131
- AffineMap (t1. m , t1. m * t2. v )
131
+ AffineMap (t1. linear , t1. linear * t2. translation )
132
132
end
133
133
134
134
function compose (t1:: AffineMap , t2:: AffineMap )
135
- AffineMap (t1. m * t2. m , t1. v + t1. m * t2. v )
135
+ AffineMap (t1. linear * t2. linear , t1. translation + t1. linear * t2. translation )
136
136
end
137
137
138
138
function compose (t1:: AffineMap , t2:: LinearMap )
139
- AffineMap (t1. m * t2. m , t1. v )
139
+ AffineMap (t1. linear * t2. linear , t1. translation )
140
140
end
141
141
142
142
function compose (t1:: LinearMap , t2:: AffineMap )
143
- AffineMap (t1. m * t2. m , t1. m * t2. v )
143
+ AffineMap (t1. linear * t2. linear , t1. linear * t2. translation )
144
144
end
145
145
146
146
function compose (t1:: AffineMap , t2:: Translation )
147
- AffineMap (t1. m , t1. v + t1. m * t2. v )
147
+ AffineMap (t1. linear , t1. translation + t1. linear * t2. translation )
148
148
end
149
149
150
150
function compose (t1:: Translation , t2:: AffineMap )
151
- AffineMap (t2. m , t1. v + t2. v )
151
+ AffineMap (t2. linear , t1. translation + t2. translation )
152
152
end
153
153
154
154
function Base. inv (trans:: AffineMap )
155
- m_inv = inv (trans. m )
156
- AffineMap (m_inv, m_inv * (- trans. v ))
155
+ m_inv = inv (trans. linear )
156
+ AffineMap (m_inv, m_inv * (- trans. translation ))
157
157
end
158
158
159
159
function Base. isapprox (t1:: AffineMap , t2:: AffineMap ; kwargs... )
160
- isapprox (t1. m , t2. m ; kwargs... ) &&
161
- isapprox (t1. v , t2. v ; kwargs... )
160
+ isapprox (t1. linear , t2. linear ; kwargs... ) &&
161
+ isapprox (t1. translation , t2. translation ; kwargs... )
162
162
end
163
163
164
164
function Base. isapprox (t1:: AffineMap , t2:: Translation ; kwargs... )
165
- isapprox (vecnorm (t1. m ), 0 ; kwargs... ) &&
166
- isapprox (t1. v , t2. v ; kwargs... )
165
+ isapprox (vecnorm (t1. linear ), 0 ; kwargs... ) &&
166
+ isapprox (t1. translation , t2. translation ; kwargs... )
167
167
end
168
168
169
169
function Base. isapprox (t1:: Translation , t2:: AffineMap ; kwargs... )
170
- isapprox (vecnorm (t2. m ), 0 ; kwargs... ) &&
171
- isapprox (t1. v , t2. v ; kwargs... )
170
+ isapprox (vecnorm (t2. linear ), 0 ; kwargs... ) &&
171
+ isapprox (t1. translation , t2. translation ; kwargs... )
172
172
end
173
173
174
174
function Base. isapprox (t1:: AffineMap , t2:: LinearMap ; kwargs... )
175
- isapprox (t1. m , t2. m ; kwargs... ) &&
176
- isapprox (vecnorm (t1. v ), 0 ; kwargs... )
175
+ isapprox (t1. linear , t2. linear ; kwargs... ) &&
176
+ isapprox (vecnorm (t1. translation ), 0 ; kwargs... )
177
177
end
178
178
179
179
function Base. isapprox (t1:: LinearMap , t2:: AffineMap ; kwargs... )
180
- isapprox (t1. m , t2. m ; kwargs... ) &&
181
- isapprox (0 , vecnorm (t2. v ); kwargs... )
180
+ isapprox (t1. linear , t2. linear ; kwargs... ) &&
181
+ isapprox (0 , vecnorm (t2. translation ); kwargs... )
182
182
end
183
183
184
184
185
185
function Base.:(== )(t1:: AffineMap , t2:: Translation )
186
- vecnorm (t1. m ) == 0 &&
187
- t1. v == t2. v
186
+ vecnorm (t1. linear ) == 0 &&
187
+ t1. translation == t2. translation
188
188
end
189
189
190
190
function Base.:(== )(t1:: Translation , t2:: AffineMap )
191
- vecnorm (t2. m ) == 0 &&
192
- t1. v == t2. v
191
+ vecnorm (t2. linear ) == 0 &&
192
+ t1. translation == t2. translation
193
193
end
194
194
195
195
function Base.:(== )(t1:: AffineMap , t2:: LinearMap )
196
- t1. m == t2. m &&
197
- vecnorm (t1. v ) == 0
196
+ t1. linear == t2. linear &&
197
+ vecnorm (t1. translation ) == 0
198
198
end
199
199
200
200
function Base.:(== )(t1:: LinearMap , t2:: AffineMap )
201
- t1. m == t2. m &&
202
- 0 == vecnorm (t2. v )
201
+ t1. linear == t2. linear &&
202
+ 0 == vecnorm (t2. translation )
203
203
end
204
204
205
205
recenter (trans:: AbstractMatrix , origin:: AbstractVector ) = recenter (LinearMap (trans), origin)
206
206
207
- transform_deriv (trans:: AffineMap , x) = trans. m
207
+ transform_deriv (trans:: AffineMap , x) = trans. linear
208
208
# TODO transform_deriv_params
0 commit comments