Skip to content

Commit

Permalink
formatting/coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
icweaver committed May 14, 2021
1 parent 36b1923 commit b82295f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/orbits/simple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,27 @@ function SimpleOrbit(;period, duration, t0=zero(period), b=0.0)
speed = 2.0 * sqrt(1.0 - b^2) / duration
ref_time = t0 - half_period
# normalize time types
period, t0, duration, half_period, ref_time = promote(period, t0, duration, half_period, ref_time)
period, t0, duration, half_period, ref_time = promote(period, t0, duration, half_period, ref_time)
SimpleOrbit(period, t0, b, duration, speed, half_period, ref_time)
end


period(orbit::SimpleOrbit) = orbit.period
duration(orbit::SimpleOrbit) = orbit.duration

relative_time(orbit::SimpleOrbit, t) = mod(t - orbit.ref_time, orbit.period) - orbit.half_period
relative_time(orbit::SimpleOrbit, t) = mod(t - orbit.ref_time, period(orbit)) - orbit.half_period

function relative_position(orbit::SimpleOrbit, t)
Δt = relative_time(orbit, t)
x = orbit.speed * Δt
y = orbit.b
z = abs(Δt) < 0.5 * orbit.duration ? one(x) : -one(x)
z = abs(Δt) < 0.5 * duration(orbit) ? one(x) : -one(x)
return SA[x, y, z]
end

# TODO: if texp, ϵ += 0.5 * texp
#function in_transit(orbit::SimpleOrbit, t)
# Δt = relative_time.(orbit, t)
# ϵ = 0.5 * orbit.duration
# ϵ = 0.5 * duration(orbit)
# return findall(x -> abs(x) < ϵ, Δt)
#end
#function in_transit(orbit::SimpleOrbit, t, r)
Expand All @@ -60,20 +59,20 @@ function flip(orbit::SimpleOrbit, ror)
b = orbit.b / ror
speed = orbit.speed / ror
ref_time = orbit.t0
return SimpleOrbit(orbit.period, t0, b, orbit.duration, speed, orbit.half_period, ref_time)
return SimpleOrbit(period(orbit), t0, b, duration(orbit), speed, orbit.half_period, ref_time)
end

function Base.show(io::IO, orbit::SimpleOrbit)
T = orbit.duration
P = orbit.period
T = duration(orbit)
P = period(orbit)
b = orbit.b
t0 = orbit.t0
print(io, "SimpleOrbit(P=$P, T=$T, t0=$t0, b=$b)")
end

function Base.show(io::IO, ::MIME"text/plain", orbit::SimpleOrbit)
T = orbit.duration
P = orbit.period
T = duration(orbit)
P = period(orbit)
b = orbit.b
t0 = orbit.t0
print(io,
Expand Down

0 comments on commit b82295f

Please sign in to comment.