Skip to content
Snippets Groups Projects
Commit 9bb3c02c authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Merge branch 'add-angle' into 'main'

Add angle

See merge request !26
parents 8caed419 d791bb21
No related branches found
Tags v0.17.1
1 merge request!26Add angle
......@@ -57,7 +57,7 @@ Julia 1.9:
docs:
image: docker.km3net.de/base/julia:1.8-tex
image: docker.km3net.de/base/julia:1.9-tex
stage: docs
script:
- |
......
name = "KM3io"
uuid = "2cab5852-6f21-4982-99b0-6a4792870cfb"
authors = ["Tamas Gal", "Johannes Schumann"]
version = "0.16.2"
version = "0.16.3"
[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
......
......@@ -150,3 +150,8 @@ bestaashower
RecStageRange
hashistory
```
### Math
```@docs
angle
```
......@@ -102,6 +102,7 @@ include("tools/general.jl")
include("tools/daq.jl")
include("tools/trigger.jl")
include("tools/reconstruction.jl")
include("tools/math.jl")
include("tools/helpers.jl")
include("physics.jl")
......
"""
Calculate the angle between two vectors.
"""
Base.angle(d1::Direction, d2::Direction) = acos(min(dot(normalize(d1), normalize(d2)), 1))
Base.angle(a::T, b::T) where {T<:Union{KM3io.AbstractCalibratedHit, KM3io.PMT}} = Base.angle(a.dir, b.dir)
Base.angle(a, b::Union{KM3io.AbstractCalibratedHit, KM3io.PMT}) = Base.angle(a, b.dir)
Base.angle(a::Union{KM3io.AbstractCalibratedHit, KM3io.PMT}, b) = Base.angle(a.dir, b)
......@@ -327,3 +327,11 @@ end
@assert 111 == length(mc_event.mc_hits)
@assert 4 == length(mc_event.mc_trks)
end
@testset "math" begin
@test 0 == angle(Direction(1.,0,0), Direction(1.,0,0))
@test π/2 angle(Direction(1.,0,0), Direction(0.,1,0))
@test π/2 angle(Direction(1.,0,0), Direction(0.,0,1))
@test π angle(Direction(1.,0,0), Direction(-1.,0,0))
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment