Skip to content

Commit

Permalink
Fix bug Rho found in centroid
Browse files Browse the repository at this point in the history
  • Loading branch information
brenhinkeller committed Aug 2, 2023
1 parent 93f19d4 commit 607f4d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/utilities/GIS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@
function spherical(x::Number, y::Number, z::Number)
ρ = sqrt(x^2 + y^2 + z^2)
φ = acos(z/ρ)
θ = atan(y/x)
θ = atan(y,x)
return ρ, φ, θ
end
export spherical
Expand Down
5 changes: 4 additions & 1 deletion test/testUtilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@

# Centroid of a set of lats and lons on a sphere
lats, lons = [-1, 1, 0, 0.], [0, 0, -1, 1.]
@test all(StatGeochem.centroid(lats, lons) .≈ (0.0, 0.0))
@test all(centroid(lats, lons) .≈ (0.0, 0.0))
lats, lons = [43.69852352,43.69852385,43.69944918,43.69945593,], [-116.0948702,-116.0936334,-116.0936182,-116.0948765,];
@test all(centroid(lats, lons) .≈ (43.698988121696146, -116.0942495750004))

# Maximum arc-degree distance between a list of points on a sphere
lats, lons = [-1, 1, 0, 0.], [0, 0, -1, 1.]
@test all(dist_uncert(lats, lons) .≈ (0.0, 0.0, 1.0))
lats, lons = [0, 0, 0, 0], [0, 30, 23, 90]
@test all(dist_uncert(lats, lons) .≈ (0.0, 34.15788270532762, 45.0))
Expand Down

0 comments on commit 607f4d6

Please sign in to comment.