Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rjdverbeek committed May 25, 2020
1 parent b2e5714 commit 69077e9
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 45 deletions.
3 changes: 3 additions & 0 deletions Project.toml
Expand Up @@ -3,6 +3,9 @@ uuid = "cc87a3b2-3706-4f35-b5b4-b2c85061916d"
authors = ["René Verbeek"]
version = "0.5.0"

[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[compat]
julia = "1.4.1"

Expand Down
3 changes: 1 addition & 2 deletions docs/src/index.md
Expand Up @@ -8,8 +8,7 @@ Private = false

## Types
```@docs
Point_rad
Point_deg
Point
```

## Functions
Expand Down
7 changes: 4 additions & 3 deletions src/Navigation.jl
Expand Up @@ -8,6 +8,7 @@ These methods are not to be used for operational purposes.
Implemented Functions:
* distance
* angular_distance
* bearing
* final_bearing
* midpoint
Expand All @@ -28,9 +29,9 @@ Implemented Types:
Implemented constants:
* Rₑ_m Radius Earth in [m]
Based on
source: www.movable-type.co.uk/scripts/latlong.html
source: edwilliams.org/avform.htm
Based on:
* source: www.movable-type.co.uk/scripts/latlong.html
* source: edwilliams.org/avform.htm
"""
module Navigation

Expand Down
6 changes: 3 additions & 3 deletions src/bearings.jl
Expand Up @@ -3,7 +3,7 @@ export bearing, final_bearing
"""
bearing(pos₁::Point, pos₂::Point)
Return the initial `bearing` of the great circle line between the
Return the initial `bearing` [deg] of the great circle line between the
positions `pos₁` and `pos₂` [deg] on a sphere.
Source: www.movable-type.co.uk/scripts/latlong.html
Expand All @@ -26,7 +26,7 @@ bearing(section::RouteSection) = bearing(section.pos₁, section.pos₂)
"""
final_bearing(pos₁::Point, pos₂::Point)
Return the `final_bearing` of the great circle line between the positions
Return the `final_bearing` [deg] of the great circle line between the positions
`pos₁` and `pos₂` [deg] on a sphere.
Source: www.movable-type.co.uk/scripts/latlong.html
Expand All @@ -38,7 +38,7 @@ end
"""
final_bearing(section::RouteSection)
Return the `final_bearing` [rad] of the route section on a sphere.
Return the `final_bearing` [deg] of the route section on a sphere.
Source: www.movable-type.co.uk/scripts/latlong.html
"""
Expand Down
29 changes: 18 additions & 11 deletions src/distances.jl
Expand Up @@ -4,8 +4,7 @@ export distance, angular_distance, cross_track_distance, along_track_distance
distance(pos₁::Point, pos₂::Point[, radius::Float64=Rₑ_m])
Return the `distance` in [m] of the great circle line between the positions `pos₁`
[deg] and `pos₂` [deg] on a sphere, with a given `radius`, calculated using the haversine
formula. The haversine gives also good estimations at short distances.
[deg] and `pos₂` [deg] on a sphere, with an optionally given `radius`.
Source: www.movable-type.co.uk/scripts/latlong.html
"""
Expand All @@ -31,15 +30,24 @@ section.pos₂, radius)
"""
angular_distance(distance::Float64[, radius::Float64=Rₑ_m])
Return the `angular_distance` in [deg] on a sphere, with a given `radius`,
calculated using distance and radius.
Return the `angular_distance` in [deg] on a sphere, with an optionally given
`radius`.
Source: www.movable-type.co.uk/scripts/latlong.html
"""
function angular_distance(distance::Float64, radius::Float64=Rₑ_m)
return rad2deg(distance/radius)
end

"""
angular_distance(pos₁::Point, pos₂::Point, radius::Float64=Rₑ_m)
Return the `angular_distance` in [deg] of the great circle line between the
positions `pos₁` [deg] and `pos₂` [deg] on a sphere, with an optionally given
`radius`.
Source: www.movable-type.co.uk/scripts/latlong.html
"""
angular_distance(pos₁::Point, pos₂::Point, radius::Float64=Rₑ_m) =
angular_distance(distance(pos₁, pos₂, radius), radius)

Expand Down Expand Up @@ -105,20 +113,19 @@ function cross_track_distance(∠distance₁₃::Float64, bearing₁₂::Float64
end

"""
along_track_distance(pos₁::Point, pos₂::Point, pos₃::Point[,
radius::Float64=Rₑ_m])
along_track_distance(pos₁::Point, pos₂::Point, pos₃::Point[,radius::Float64=Rₑ_m])
The `along_track_distance` from the start point `pos₁` [deg] to the closest
point on the great circle path (defined by points `pos₁` and `pos₂` [deg]) to
the point `pos₃` [deg]. The `radius` of the earth can also be given.
the point `pos₃` [deg]. Optionally a different `radius` for the earth can be used.
Source: www.movable-type.co.uk/scripts/latlong.html
"""
function along_track_distance(pos₁::Point, pos₂::Point, pos₃::Point,
radius::Float64=Rₑ_m)
∠distance₁₃ = angular_distance(pos₁, pos₃, radius)
∠cross_track_distance = rad2deg(cross_track_distance(pos₁, pos₂, pos₃, radius)/radius)
return along_track_distance(∠distance₁₃, ∠cross_track_distance, radius)
cross_track_∠distance = rad2deg(cross_track_distance(pos₁, pos₂, pos₃, radius)/radius)
return along_track_distance(∠distance₁₃, cross_track_∠distance, radius)
end

"""
Expand All @@ -128,8 +135,8 @@ end
The `along_track_distance` from the start point `pos₁` [deg] to the closest
point on the great circle path (defined by angular distance `∠distance₁₃` [deg]
between `pos₁` and `pos₃` [deg] and the cross track angular distance
`cross_track_∠distance` [deg]) to the point `pos₃` [deg]. The `radius` of the
earth can also be given.
`cross_track_∠distance` [deg]) to the point `pos₃` [deg]. Optionally a
different `radius` for the earth can be used.
Source: www.movable-type.co.uk/scripts/latlong.html
"""
Expand Down
35 changes: 17 additions & 18 deletions src/points.jl
Expand Up @@ -21,7 +21,7 @@ end
"""
midpoint(section::RouteSection)
Return the half-way point `midpoint` (Point) on the route section on a sphere.
Return the half-way point `midpoint` [deg] on the route section on a sphere.
Source: www.movable-type.co.uk/scripts/latlong.html
"""
Expand Down Expand Up @@ -83,14 +83,13 @@ function destination_point(start_pos::Point, distance::Float64,
end

"""
intersection_point(pos₁::Point, pos₂::Point, bearing₁₃::Float64,
bearing₂₃::Float64)
intersection_point(pos₁::Point, pos₂::Point, bearing₁₃::Float64, bearing₂₃::Float64)
Return the intersection point `pos₃` [deg] of two great circle paths given two
start points [deg] `pos₁` and `pos₂` and two bearings [deg] from `pos₁` to
`pos₃`, and from `pos₂` to `pos₃`.
start points [deg] `pos₁` and `pos₂` [deg] and two bearings [deg] from `pos₁` to
`pos₃` [deg], and from `pos₂` to `pos₃` [deg].
Under certain circumstances the results can be an ∞ or ambiguous solution.
Under certain circumstances the results can be an ∞ or *ambiguous solution*.
Source: edwilliams.org/avform.htm
"""
Expand Down Expand Up @@ -142,17 +141,17 @@ end
# println(airspace.bounding_box)
# end

#TODO Source for longitude
"""
closest_point_to_pole(point::Point, bearing::Float64)
closest_point_to_pole(starting_point::Point, bearing::Float64)
Given a starting point [deg] and initial bearing [deg] calculate the
closest point to the next pole encountered.
Given a `starting_point` [deg] and initial `bearing` [deg] calculate the
closest point [deg] to the next pole encountered.
Source: https://www.movable-type.co.uk/scripts/latlong.html
#TODO Source for longitude
"""
function closest_point_to_pole(point::Point, bearing::Float64)
pnt = normalize(point)
function closest_point_to_pole(starting_point::Point, bearing::Float64)
pnt = normalize(starting_point)
brg = normalize(bearing, -180.0, 180.0)
max_lat = max_latitude(pnt.ϕ, brg)
max_lon = pnt.λ + atand(1.0, tand(brg)sind(pnt.ϕ))
Expand All @@ -161,24 +160,24 @@ function closest_point_to_pole(point::Point, bearing::Float64)
end

"""
max_latitude(lat::Float64, bearing::Float64)
max_latitude(latitude::Float64, bearing::Float64)
Using Clairaut's formula it is possible to calculate the maximum latitude [deg]
of a great circle path, give a bearing `bearing` [deg] and latitude
`lat` [deg] on the great circle.
of a great circle path, given a `bearing` [deg] and `latitude` [deg] on the
great circle.
The minimum latitude is -max_latitude
Source: https://www.movable-type.co.uk/scripts/latlong.html
"""
function max_latitude(lat::Float64, bearing::Float64)
return acosd(abs(sind(bearing)cosd(lat)))
function max_latitude(latitude::Float64, bearing::Float64)
return acosd(abs(sind(bearing)cosd(latitude)))
end

"""
opposite_point(point::Point)
The point at the opposite site of the Earth.
The point at the opposite site of the Sphere.
"""
function opposite_point(point::Point)
normalize(Point(-point.ϕ, point.λ+180.0))
Expand Down
14 changes: 8 additions & 6 deletions src/wind.jl
Expand Up @@ -4,22 +4,24 @@ export Vground, head_wind, cross_wind
Vground(Vtas::Float64, Vwind::Float64, ∠wind::Float64, course::Float64)
Return the ground speed `Vground` [m/s] given the `course` [deg], airspeed
`Vtas` [m/s], wind speed `Vwind`[m/s] and wind direction `∠wind` [deg]. The
speeds need to use the same speed unit ([m/s] or [kts] or [km/h]).
`Vtas` [m/s], wind speed `Vwind`[m/s] and wind direction (from) `∠wind` [deg].
source: edwilliams.org/avform.htm
"""
function Vground(Vtas::Float64, Vwind::Float64, ∠wind::Float64, course::Float64)
swc = (Vwind / Vtas) * sind(∠wind - course)
return Vtas * (1-swc*swc) - Vwind * cosd(∠wind - course)
if abs(swc) > 1.0
return NaN
end
return Vtas * (1-swc^2) - Vwind * cosd(∠wind - course)
end

"""
head_wind(Vwind::Float64, ∠wind::Float64, course::Float64)
Return the `head_wind` [m/s] component for a given wind speed `Vwind` [m/s],
`course` [deg], and wind direction `∠wind` [deg]. A tail-wind is a negative
head-wind.
`course` [deg], and wind direction (from) `∠wind` [deg]. A tail-wind is a
negative head-wind.
source: edwilliams.org/avform.htm
"""
Expand All @@ -31,7 +33,7 @@ end
cross_wind(Vwind::Float64, ∠wind::Float64, course::Float64)
Return the `cross_wind` [m/s] component for a given wind speed `Vwind` [m/s],
`course` [deg], and wind direction `∠wind` [deg]. A positive cross-wind
`course` [deg], and wind direction (from) `∠wind` [deg]. A positive cross-wind
component indicates a wind from the right.
source: edwilliams.org/avform.htm
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Expand Up @@ -3,7 +3,7 @@ using Test

@testset "Navigation.jl" begin
tests = ["utility", "distances", "bearings", "points", "wind"]
# tests = ["network"]
# tests = ["utility"]

for t in tests
include("$(t).jl")
Expand Down
1 change: 0 additions & 1 deletion test/wind.jl
Expand Up @@ -5,5 +5,4 @@

@test head_wind(20.0, 60.0, 30.0) 17.32 atol = 0.01
@test cross_wind(20.0, 60.0, 30.0) 10.00 atol = 0.01

end

0 comments on commit 69077e9

Please sign in to comment.