JuliaGeometry / CoordinateTransformations.jl

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

Error in the SphericalFromCartesian function #92

Open LingyiZou opened 7 months ago

LingyiZou commented 7 months ago

The results of the following function seem wrong to me,

function (::SphericalFromCartesian)(x::AbstractVector) length(x) == 3 || error("Spherical transform takes a 3D coordinate")

Spherical(hypot(x[1], x[2], x[3]), atan(x[2], x[1]), atan(x[3], hypot(x[1], x[2])))

end

Should the fourth line be changed to this?

function (::SphericalFromCartesian)(x::AbstractVector) length(x) == 3 || error("Spherical transform takes a 3D coordinate")

Spherical(hypot(x[1], x[2], x[3]), atan(x[2], x[1]), atan(hypot(x[1], x[2]), x[3]))

end