4
4
"""
5
5
`Polar{T}(r::T, θ::T)` - 2D polar coordinates
6
6
"""
7
- immutable Polar{T}
7
+ struct Polar{T}
8
8
r:: T
9
9
θ:: T
10
10
end
@@ -14,9 +14,9 @@ Base.eltype{T}(::Polar{T}) = T
14
14
Base. eltype {T} (:: Type{Polar{T}} ) = T
15
15
16
16
" `PolarFromCartesian()` - transformation from `AbstractVector` of length 2 to `Polar` type"
17
- immutable PolarFromCartesian <: Transformation ; end
17
+ struct PolarFromCartesian <: Transformation ; end
18
18
" `CartesianFromPolar()` - transformation from `Polar` type to `SVector{2}` type"
19
- immutable CartesianFromPolar <: Transformation ; end
19
+ struct CartesianFromPolar <: Transformation ; end
20
20
21
21
Base. show (io:: IO , trans:: PolarFromCartesian ) = print (io, " PolarFromCartesian()" )
22
22
Base. show (io:: IO , trans:: CartesianFromPolar ) = print (io, " CartesianFromPolar()" )
@@ -57,8 +57,8 @@ compose(::CartesianFromPolar, ::PolarFromCartesian) = IdentityTransformation()
57
57
58
58
# For convenience
59
59
Base. convert (:: Type{Polar} , v:: AbstractVector ) = PolarFromCartesian ()(v)
60
- @inline Base. convert {V <: AbstractVector} (:: Type{V} , p:: Polar ) = convert (V, CartesianFromPolar ()(p))
61
- @inline Base. convert {V <: StaticVector} (:: Type{V} , p:: Polar ) = convert (V, CartesianFromPolar ()(p))
60
+ @inline Base. convert (:: Type{V} , p:: Polar ) where {V <: AbstractVector } = convert (V, CartesianFromPolar ()(p))
61
+ @inline Base. convert (:: Type{V} , p:: Polar ) where {V <: StaticVector } = convert (V, CartesianFromPolar ()(p))
62
62
63
63
64
64
# ############################
@@ -67,7 +67,7 @@ Base.convert(::Type{Polar}, v::AbstractVector) = PolarFromCartesian()(v)
67
67
"""
68
68
Spherical(r, θ, ϕ) - 3D spherical coordinates
69
69
"""
70
- immutable Spherical{T}
70
+ struct Spherical{T}
71
71
r:: T
72
72
θ:: T
73
73
ϕ:: T
@@ -80,7 +80,7 @@ Base.eltype{T}(::Type{Spherical{T}}) = T
80
80
"""
81
81
Cylindrical(r, θ, z) - 3D cylindrical coordinates
82
82
"""
83
- immutable Cylindrical{T}
83
+ struct Cylindrical{T}
84
84
r:: T
85
85
θ:: T
86
86
z:: T
@@ -91,17 +91,17 @@ Base.eltype{T}(::Cylindrical{T}) = T
91
91
Base. eltype {T} (:: Type{Cylindrical{T}} ) = T
92
92
93
93
" `SphericalFromCartesian()` - transformation from 3D point to `Spherical` type"
94
- immutable SphericalFromCartesian <: Transformation ; end
94
+ struct SphericalFromCartesian <: Transformation ; end
95
95
" `CartesianFromSpherical()` - transformation from `Spherical` type to `SVector{3}` type"
96
- immutable CartesianFromSpherical <: Transformation ; end
96
+ struct CartesianFromSpherical <: Transformation ; end
97
97
" `CylindricalFromCartesian()` - transformation from 3D point to `Cylindrical` type"
98
- immutable CylindricalFromCartesian <: Transformation ; end
98
+ struct CylindricalFromCartesian <: Transformation ; end
99
99
" `CartesianFromCylindrical()` - transformation from `Cylindrical` type to `SVector{3}` type"
100
- immutable CartesianFromCylindrical <: Transformation ; end
100
+ struct CartesianFromCylindrical <: Transformation ; end
101
101
" `CylindricalFromSpherical()` - transformation from `Spherical` type to `Cylindrical` type"
102
- immutable CylindricalFromSpherical <: Transformation ; end
102
+ struct CylindricalFromSpherical <: Transformation ; end
103
103
" `SphericalFromCylindrical()` - transformation from `Cylindrical` type to `Spherical` type"
104
- immutable SphericalFromCylindrical <: Transformation ; end
104
+ struct SphericalFromCylindrical <: Transformation ; end
105
105
106
106
Base. show (io:: IO , trans:: SphericalFromCartesian ) = print (io, " SphericalFromCartesian()" )
107
107
Base. show (io:: IO , trans:: CartesianFromSpherical ) = print (io, " CartesianFromSpherical()" )
@@ -170,7 +170,7 @@ transform_deriv_params(::CylindricalFromCartesian, x::AbstractVector) = error("C
170
170
function (:: CartesianFromCylindrical )(x:: Cylindrical )
171
171
SVector (x. r * cos (x. θ), x. r * sin (x. θ), x. z)
172
172
end
173
- function transform_deriv {T} (:: CartesianFromCylindrical , x:: Cylindrical{T} )
173
+ function transform_deriv (:: CartesianFromCylindrical , x:: Cylindrical{T} ) where {T}
174
174
sθ = sin (x. θ)
175
175
cθ = cos (x. θ)
176
176
@SMatrix [cθ - x. r* sθ zero (T) ;
@@ -227,10 +227,10 @@ compose(::SphericalFromCylindrical, ::CylindricalFromCartesian) = SphericalFromC
227
227
Base. convert (:: Type{Spherical} , v:: AbstractVector ) = SphericalFromCartesian ()(v)
228
228
Base. convert (:: Type{Cylindrical} , v:: AbstractVector ) = CylindricalFromCartesian ()(v)
229
229
230
- Base. convert {V <: AbstractVector} (:: Type{V} , s:: Spherical ) = convert (V, CartesianFromSpherical ()(s))
231
- Base. convert {V <: AbstractVector} (:: Type{V} , c:: Cylindrical ) = convert (V, CartesianFromCylindrical ()(c))
232
- Base. convert {V <: StaticVector} (:: Type{V} , s:: Spherical ) = convert (V, CartesianFromSpherical ()(s))
233
- Base. convert {V <: StaticVector} (:: Type{V} , c:: Cylindrical ) = convert (V, CartesianFromCylindrical ()(c))
230
+ Base. convert (:: Type{V} , s:: Spherical ) where {V <: AbstractVector } = convert (V, CartesianFromSpherical ()(s))
231
+ Base. convert (:: Type{V} , c:: Cylindrical ) where {V <: AbstractVector } = convert (V, CartesianFromCylindrical ()(c))
232
+ Base. convert (:: Type{V} , s:: Spherical ) where {V <: StaticVector } = convert (V, CartesianFromSpherical ()(s))
233
+ Base. convert (:: Type{V} , c:: Cylindrical ) where {V <: StaticVector } = convert (V, CartesianFromCylindrical ()(c))
234
234
235
235
Base. convert (:: Type{Spherical} , c:: Cylindrical ) = SphericalFromCylindrical ()(c)
236
236
Base. convert (:: Type{Cylindrical} , s:: Spherical ) = CylindricalFromSpherical ()(s)
0 commit comments