JuliaGeometry / JuliaGeometry/CoordinateTransformations.jl

Error in the SphericalFromCartesian function

Open
#92 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
185
Forks
24
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating SphericalFromCartesian and inspecting the Spherical constructor and related coordinate-transform definitions. Verify which spherical-angle convention the package expects, then compare both formulas against representative 3D coordinates. Done means the function follows the established convention and the relevant behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.