@@ -16,11 +16,11 @@ Translation(x,y) = Translation(Vec(x,y))
16
16
Translation (x,y,z) = Translation (Vec (x,y,z))
17
17
Base. show (io:: IO , trans:: Translation ) = print (io, " Translation$((trans. dx... )) " )
18
18
19
- function transform (trans:: Translation , x)
19
+ @compat function (trans:: Translation )( x)
20
20
x + trans. dx
21
21
end
22
22
23
- transform (trans:: Translation , x:: Tuple ) = Tuple (Vec (x) + trans. dx)
23
+ @compat (trans:: Translation )( x:: Tuple ) = Tuple (Vec (x) + trans. dx)
24
24
25
25
Base. inv (trans:: Translation ) = Translation (- trans. dx)
26
26
@@ -60,28 +60,28 @@ function Rotation2D(a)
60
60
end
61
61
62
62
# A variety of specializations for all occassions!
63
- function transform (trans:: Rotation2D , x:: FixedVector{2} )
63
+ @compat function (trans:: Rotation2D )( x:: FixedVector{2} )
64
64
(sincos, x2) = promote (Vec (trans. sin, trans. cos), x)
65
65
(typeof (x2))(x[1 ]* sincos[2 ] - x[2 ]* sincos[1 ], x[1 ]* sincos[1 ] + x[2 ]* sincos[2 ])
66
66
end
67
67
68
- transform (trans:: Rotation2D , x:: NTuple{2} ) = (x[1 ]* trans. cos - x[2 ]* trans. sin, x[1 ]* trans. sin + x[2 ]* trans. cos)
69
- transform {T1,T2} (trans:: Rotation2D{T1} , x:: Vector{T2} ) = [x[1 ]* trans. cos - x[2 ]* trans. sin, x[1 ]* trans. sin + x[2 ]* trans. cos]
68
+ @compat (trans:: Rotation2D )( x:: NTuple{2} ) = (x[1 ]* trans. cos - x[2 ]* trans. sin, x[1 ]* trans. sin + x[2 ]* trans. cos)
69
+ @compat (trans:: Rotation2D{T1} ){T1,T2}( x:: Vector{T2} ) = [x[1 ]* trans. cos - x[2 ]* trans. sin, x[1 ]* trans. sin + x[2 ]* trans. cos]
70
70
71
71
# E.g. for ArrayFire, this might work better than the below?
72
- function transform {T1,T2} (trans:: Rotation2D{T1} , x:: AbstractVector{T2} )
72
+ @compat function (trans:: Rotation2D{T1} ){T1,T2}( x:: AbstractVector{T2} )
73
73
out = similar (x, promote_type (T1,T2))
74
74
out[1 ] = x[1 ]* trans. cos - x[2 ]* trans. sin
75
75
out[2 ] = x[1 ]* trans. sin + x[2 ]* trans. cos
76
76
return out
77
77
end
78
78
79
- function transform (trans:: Rotation2D , x)
79
+ @compat function (trans:: Rotation2D )( x)
80
80
[ trans. cos - trans. sin;
81
81
trans. sin trans. cos ] * x
82
82
end
83
83
84
- function transform (trans:: Rotation2D , x:: Polar )
84
+ @compat function (trans:: Rotation2D )( x:: Polar )
85
85
Polar (x. r, x. θ + trans. angle)
86
86
end
87
87
@@ -163,16 +163,16 @@ Base.isapprox(a::Rotation, b::Rotation; kwargs...) = isapprox(a.matrix, b.matrix
163
163
Base. isapprox {T} (a:: Rotation{T} , b:: Rotation{T} ; kwargs... ) = isapprox (a. matrix, b. matrix; kwargs... ) && isapprox (a. rotation, b. rotation; kwargs... )
164
164
Base. isapprox (a:: Rotation{Void} , b:: Rotation{Void} ; kwargs... ) = isapprox (a. matrix, b. matrix; kwargs... )
165
165
166
- function transform (trans:: Rotation , x)
166
+ @compat function (trans:: Rotation )( x)
167
167
trans. matrix * x
168
168
end
169
169
170
- function transform (trans:: Rotation , x:: FixedVector{3} )
170
+ @compat function (trans:: Rotation )( x:: FixedVector{3} )
171
171
(m, x2) = promote (trans. matrix, x)
172
172
(typeof (x2))(m * Vec (x2))
173
173
end
174
174
175
- transform (trans:: Rotation , x:: Tuple ) = Tuple (transform ( trans, Vec (x)))
175
+ @compat (trans:: Rotation )( x:: Tuple ) = Tuple (trans ( Vec (x)))
176
176
177
177
transform_deriv (trans:: Rotation , x) = trans. matrix # It's a linear transformation, so this is easy!
178
178
@@ -323,13 +323,13 @@ Base.show(io::IO, r::RotationYZ) = print(io, "RotationYZ($(r.angle))")
323
323
Base. show (io:: IO , r:: RotationZX ) = print (io, " RotationZX($(r. angle) )" )
324
324
325
325
# It's a little fiddly to support all possible point container types, but this should do a good majority of them!
326
- transform (trans:: RotationXY , x:: Vector ) = [x[1 ]* trans. cos - x[2 ]* trans. sin, x[1 ]* trans. sin + x[2 ]* trans. cos, x[3 ]]
327
- transform (trans:: RotationXY , x:: NTuple{3} ) = (x[1 ]* trans. cos - x[2 ]* trans. sin, x[1 ]* trans. sin + x[2 ]* trans. cos, x[3 ])
328
- function transform (trans:: RotationXY , x:: FixedVector{3} )
326
+ @compat (trans:: RotationXY )( x:: Vector ) = [x[1 ]* trans. cos - x[2 ]* trans. sin, x[1 ]* trans. sin + x[2 ]* trans. cos, x[3 ]]
327
+ @compat (trans:: RotationXY )( x:: NTuple{3} ) = (x[1 ]* trans. cos - x[2 ]* trans. sin, x[1 ]* trans. sin + x[2 ]* trans. cos, x[3 ])
328
+ @compat function (trans:: RotationXY )( x:: FixedVector{3} )
329
329
(sincos, x2) = promote (Vec (trans. sin, trans. cos), x)
330
330
(typeof (x2))(x[1 ]* sincos[2 ] - x[2 ]* sincos[1 ], x[1 ]* sincos[1 ] + x[2 ]* sincos[2 ], x2[3 ])
331
331
end
332
- function transform {T} (trans:: RotationXY{T} , x)
332
+ @compat function (trans:: RotationXY{T} ){T}( x)
333
333
Z = zero (T)
334
334
I = one (T)
335
335
@@ -338,13 +338,13 @@ function transform{T}(trans::RotationXY{T}, x)
338
338
Z Z I ] * x
339
339
end
340
340
341
- transform (trans:: RotationYZ , x:: Vector ) = [x[1 ], x[2 ]* trans. cos - x[3 ]* trans. sin, x[2 ]* trans. sin + x[3 ]* trans. cos]
342
- transform (trans:: RotationYZ , x:: NTuple{3} ) = (x[1 ], x[2 ]* trans. cos - x[3 ]* trans. sin, x[2 ]* trans. sin + x[3 ]* trans. cos)
343
- function transform (trans:: RotationYZ , x:: FixedVector{3} )
341
+ @compat (trans:: RotationYZ )( x:: Vector ) = [x[1 ], x[2 ]* trans. cos - x[3 ]* trans. sin, x[2 ]* trans. sin + x[3 ]* trans. cos]
342
+ @compat (trans:: RotationYZ )( x:: NTuple{3} ) = (x[1 ], x[2 ]* trans. cos - x[3 ]* trans. sin, x[2 ]* trans. sin + x[3 ]* trans. cos)
343
+ @compat function (trans:: RotationYZ )( x:: FixedVector{3} )
344
344
(sincos, x2) = promote (Vec (trans. sin, trans. cos), x)
345
345
(typeof (x2))(x2[1 ], x[2 ]* sincos[2 ] - x[3 ]* sincos[1 ], x[2 ]* sincos[1 ] + x[3 ]* sincos[2 ])
346
346
end
347
- function transform {T} (trans:: RotationYZ{T} , x)
347
+ @compat function (trans:: RotationYZ{T} ){T}( x)
348
348
Z = zero (T)
349
349
I = one (T)
350
350
@@ -353,13 +353,13 @@ function transform{T}(trans::RotationYZ{T}, x)
353
353
Z trans. sin trans. cos] * x
354
354
end
355
355
356
- transform (trans:: RotationZX , x:: Vector ) = [x[3 ]* trans. sin + x[1 ]* trans. cos, x[2 ], x[3 ]* trans. cos - x[1 ]* trans. sin]
357
- transform (trans:: RotationZX , x:: NTuple{3} ) = (x[3 ]* trans. sin + x[1 ]* trans. cos, x[2 ], x[3 ]* trans. cos - x[1 ]* trans. sin)
358
- function transform (trans:: RotationZX , x:: FixedVector{3} )
356
+ @compat (trans:: RotationZX )( x:: Vector ) = [x[3 ]* trans. sin + x[1 ]* trans. cos, x[2 ], x[3 ]* trans. cos - x[1 ]* trans. sin]
357
+ @compat (trans:: RotationZX )( x:: NTuple{3} ) = (x[3 ]* trans. sin + x[1 ]* trans. cos, x[2 ], x[3 ]* trans. cos - x[1 ]* trans. sin)
358
+ @compat function (trans:: RotationZX )( x:: FixedVector{3} )
359
359
(sincos, x2) = promote (Vec (trans. sin, trans. cos), x)
360
360
(typeof (x2))(x[3 ]* sincos[1 ] + x[1 ]* sincos[2 ], x2[2 ], x[3 ]* sincos[2 ] - x[1 ]* sincos[1 ])
361
361
end
362
- function transform {T} (trans:: RotationZX{T} , x)
362
+ @compat function (trans:: RotationZX{T} ){T}( x)
363
363
Z = zero (T)
364
364
I = one (T)
365
365
0 commit comments