Skip to content

Commit ad7df20

Browse files
committed
correparticlebeam
1 parent ab6edc6 commit ad7df20

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/billiards/particles.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,17 @@ end
141141
## Aux
142142
####################################################
143143
"""
144-
particlebeam(x0, y0, φ, N, dx, ω = nothing) → ps
144+
particlebeam(x0, y0, φ, N, dx, ω = nothing, T = eltype(x0)) → ps
145145
Make `N` particles, all with direction `φ`, starting at `x0, y0`. The particles
146146
don't all have the same position, but are instead spread by up to `dx` in the
147147
direction normal to `φ`.
148+
149+
The particle element type is `T`.
148150
"""
149-
function particlebeam(x0, y0, φ, N, dx, ω = nothing, T = Float64)
150-
n = sincos(φ)
151+
function particlebeam(x0, y0, φ, N, dx, ω = nothing, T = eltype(x0))
152+
n = cossin(φ)
151153
xyφs = [
152-
T.((x0 + i*dx*n[1]/N, y0 + i*dx*n[2]/N, φ)) for i in range(-N/2, N/2; length = N)
154+
T.((x0 - i*dx*n[2]/N, y0 + i*dx*n[1]/N, φ)) for i in range(-N/2, N/2; length = N)
153155
]
154156
if isnothing(ω)
155157
ps = [Particle(z...) for z in xyφs]

0 commit comments

Comments
 (0)