Skip to content

Commit 590ed77

Browse files
committed
allow type specification for Julia billiard
1 parent 96a7713 commit 590ed77

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DynamicalBilliards"
22
uuid = "4986ee89-4ee5-5cef-b6b8-e49ba721d7a5"
33
repo = "https://github.com/JuliaDynamics/DynamicalBilliards.jl.git"
4-
version = "3.11.1"
4+
version = "3.11.2"
55

66
[deps]
77
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"

src/billiards/standard_billiards.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -293,23 +293,24 @@ end
293293
billiard_stadium = billiard_bunimovich
294294

295295
"""
296-
billiard_logo(;h=1.0, α=0.8, r=0.18, off=0.25) -> bd, ray
296+
billiard_logo(;h=1.0, α=0.8, r=0.18, off=0.25, T = Float64) -> bd, ray
297297
Create the billiard used as logo of `DynamicalBilliards` and return it
298298
along with the tuple of raysplitters.
299299
"""
300-
function billiard_logo(;h=1.0, α=0.8, r=0.18, off=0.25)
300+
function billiard_logo(;h=1.0, α=0.8, r=0.18, off=0.25, T = Float64)
301301

302302
cos6 = cos/6)
303303
β = (h - cos6*α)/cos6
304304
t = α + 2β
305-
center_of_mass = [0.0, 3*t/6]
306-
startloc = [-α/2, 0.0]
305+
(α, r, h, off, cos6, β, t) = T.((α, r, h, off, cos6, β, t))
306+
center_of_mass = T[0.0, 3*t/6]
307+
startloc = T[-α/2, 0.0]
307308

308309
# create directions of the hexagonal 6:
309-
hexvert = [(cos(2π*i/6), sin(2π*i/6)) for i in 1:6]
310+
hexvert = [T.((cos(2π*i/6), sin(2π*i/6))) for i in 1:6]
310311
dirs = [SVector{2}(hexvert[i] .- hexvert[mod1(i+1, 6)]) for i in 1:6]
311312

312-
frame = Obstacle{Float64}[]
313+
frame = Obstacle{T}[]
313314

314315
sp = startloc
315316
ep = startloc + α*dirs[1]
@@ -319,18 +320,18 @@ function billiard_logo(;h=1.0, α=0.8, r=0.18, off=0.25)
319320

320321
for i in 2:6
321322
s = iseven(i) ? β : α
322-
T = InfiniteWall #iseven(i) ? RandomWall : InfiniteWall
323+
WT = InfiniteWall #iseven(i) ? RandomWall : InfiniteWall
323324
sp = frame[i-1].ep
324325
ep = sp + s*dirs[i]
325326
normal = (w = ep .- sp; [-w[2], w[1]])
326-
push!(frame, T(sp, ep, normal, "frame $(i)"))
327+
push!(frame, WT(sp, ep, normal, "frame $(i)"))
327328
end
328329

329330

330331
# Radii of circles that compose the Julia logo
331-
offset = [0.0, off]
332+
offset = T[0.0, off]
332333

333-
R = [cos(2π/3) -sin(2π/3);
334+
R = T[cos(2π/3) -sin(2π/3);
334335
sin(2π/3) cos(2π/3)]
335336

336337

0 commit comments

Comments
 (0)