JuliaGeometry / CoordinateTransformations.jl

A fresh approach to coordinate transformations...
Other
179 stars 25 forks source link

Failure to run the code from README: Polar(SVector(1.0, 2.0)) #83

Closed hurak closed 2 weeks ago

hurak commented 1 year ago

It is stated in the main README that

However, you may find it simpler to use the convenience constructors like Polar(SVector(1.0, 2.0)).

I get an error when trying to run this snippet of code:

ulia> using StaticArrays

julia> using CoordinateTransformations

julia> Polar(SVector(1.0, 2.0))
ERROR: MethodError: no method matching Polar(::SVector{2, Float64})
Closest candidates are:
  Polar(::Any, ::Any) at ~/.julia/packages/CoordinateTransformations/9po3r/src/coordinatesystems.jl:14
Stacktrace:
 [1] top-level scope
   @ REPL[7]:1

CoordinateTransformations v0.6.2 StaticArrays v1.5.4 Julia v1.8.0-rc4

mofii commented 1 year ago

I can reproduce that. The comment was added to the README file with commit 529d950 which is 6 years ago during release 0.3.2 but even in that commit I don't see a convenience constructor in the code. There is a convenience converter, though:

julia> convert(Polar, SVector(1,2))
Polar(r=2.23606797749979, θ=1.1071487177940904 rad)
mofii commented 1 year ago

There's now a PR (#84) that adds this functionality.