Skip to content

Commit 291a22f

Browse files
jw3126waldyrious
andauthored
improve Spherical docs (#68)
Co-authored-by: Waldir Pimenta <waldyrious@gmail.com>
1 parent 242daa3 commit 291a22f

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

Project.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ uuid = "150eb455-5306-5404-9cee-2592286d6298"
33
version = "0.6.0"
44

55
[deps]
6-
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
76
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
7+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
88

99
[compat]
1010
StaticArrays = "0.11,0.12"
1111
julia = "1"
1212

1313
[extras]
14-
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
1514
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1615
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
16+
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
17+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
1718

1819
[targets]
19-
test = ["Test", "ForwardDiff", "Unitful"]
20+
test = ["Test", "ForwardDiff", "Unitful", "Documenter"]

docs/src/note.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
this directory must exist for running doctests

src/coordinatesystems.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,25 @@ Base.convert(::Type{Polar}, v::AbstractVector) = PolarFromCartesian()(v)
7373
#############################
7474
"""
7575
Spherical(r, θ, ϕ) - 3D spherical coordinates
76+
77+
There are many Spherical coordinate conventions and this library uses a somewhat exotic one.
78+
Given a vector `v` with Cartesian coordinates `xyz`, let `v_xy = [x,y,0]` be the orthogonal projection of `v` on the `xy` plane.
79+
80+
* `r` is the radius. It is given by `norm(v, 2)`.
81+
* `θ` is the azimuth. It is the angle from the x-axis to `v_xy`
82+
* `ϕ` is the latitude. It is the angle from `v_xy` to `v`.
83+
84+
```jldoctest
85+
julia> using CoordinateTransformations
86+
87+
julia> v = randn(3);
88+
89+
julia> sph = SphericalFromCartesian()(v);
90+
91+
julia> r = sph.r; θ=sph.θ; ϕ=sph.ϕ;
92+
93+
julia> v ≈ [r * cos(θ) * cos(ϕ), r * sin(θ) * cos(ϕ), r*sin(ϕ)]
94+
true
7695
"""
7796
struct Spherical{T,A}
7897
r::T

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ using CoordinateTransformations
44
using ForwardDiff: Dual, partials
55
using StaticArrays
66
using Unitful
7+
using Documenter: doctest
8+
79

810
@testset "CoordinateTransformations" begin
911

12+
doctest(CoordinateTransformations)
1013
include("core.jl")
1114
include("coordinatesystems.jl")
1215
include("affine.jl")

0 commit comments

Comments
 (0)