1
0
Fork 0
mirror of https://gitlab.rlp.net/mobitar/ReCo.jl.git synced 2024-09-19 19:01:17 +00:00
ReCo.jl/src/Geometry.jl
2021-12-16 14:54:52 +01:00

21 lines
No EOL
385 B
Julia

module Geometry
export angle2
using StaticArrays: SVector
"""
angle2(a::SVector{2,Float64}, b::SVector{2,Float64})
Returns the angle φ from vector a to b while φ ∈ [-π, π].
"""
function angle2(a::SVector{2,Float64}, b::SVector{2,Float64})
θ_a = atan(a[2], a[1])
θ_b = atan(b[2], b[1])
θ = θ_b - θ_a
return rem2pi(θ, RoundNearest)
end
end # module