Billiards

(see the examples/billiard.jl file to generate every animation)

InteractiveChaos.interactive_billiardFunction
interactive_billiard(bd::Billiard [, x, y, φ] [, ω=nothing]; kwargs...)
interactive_billiard(bd::Billiard, ps::Vector{<:AbstractParticle}; kwargs...)

Launch an interactive application that evolves particles in a dynamical billiard bd, using DynamicalBilliards.jl. Requires DynamicalBilliards.

You can either specify exactly the particles that will be used ps or provide some initial conditions x,y,φ,ω, which by default are random in the billiard. The particles are evolved in real time instead of being pre-calculated, so the application can be left to run for infinite time.

See also interactive_billiard_bmap and billiard_video.

Interaction

Push "play" to start evolving particles in the billiard, and "reset" to restore them to their (latest) initial condition. The "particles" hides or shows the particles. The "speed" slider controls the animation speed (in fact, it controls how often are the plots updated).

Clicking and dragging inside the billiard plot shows a line. When the line is selected, new particles are created that have the direction of this line, as well as its starting position, using the function particlebeam from DynamicalBilliards.

Further keywords

  • N = 100 : if exact particles are not given, N are created. Otherwise it is length(ps).
  • dx = 0.01 : width of the particle beam.
  • dt = 0.001 : time resolution of the animation.
  • tail = 1000 : length of the tail of the particles (multiplies dt).
  • colors = JULIADYNAMICS_COLORS : If a symbol (colormap name) each particle gets a color from the map. If Vector of length N, each particle gets a color form the vector. If Vector with length < N, linear interpolation across contained colors is done.
  • fade = true : Whether to add fadeout to the particle tail.
  • sleept = nothing : If the slowest speed of the animation is already too fast, give a small number to sleept.
  • plot_particles = true : If false, the particles are not plotted (as balls and arrows). This makes the application faster (you cannot show them again with the button).
source

For example, running

using DynamicalBilliards, InteractiveChaos, Makie
bd, = billiard_logo(T = Float32)
interactive_billiard(bd, 1f0, tail = 1000)

gives


InteractiveChaos.billiard_videoFunction
billiard(file, bd::Billiard [, x, y, φ] [, ω=nothing]; kwargs...)
billiard(file, bd::Billiard, ps::Vector{<:AbstractParticle}; kwargs...)

Perform the same animation like in interactive_billiard, but there is no interaction; the result is saved directly as a video in file (no buttons are shown).

Keywords

  • N, dt, tail, dx, colors, plot_particles, fade: same as interactive_billiard, but with a bit "denser" defaults. plot_particles is false by default here.
  • speed = 5: Animation "speed" (how many dt steps are taken before a frame is recorded)
  • frames = 1000: amount of frames to record.
  • framerate = 60: exported framerate.
  • backgroundcolor = :white.
  • res = nothing: resolution of the frames. If nothing, a resolution matching the the billiard aspect ratio is estimated. Otherwise pass a 2-tuple.
source

Here is a video in the style of 3Blue1Brown


InteractiveChaos.interactive_billiard_bmapFunction
interactive_billiard_bmap(bd::Billiard, ω=nothing; kwargs...)

Launch an interactive application whose left part is interactive_billiard and whose write part is an interactive boundary map of the billiard (see "Phase spaces" in DynamicalBilliards.jl).

A particle evolved in the real billiard is also shown on the boundary map. All interaction of the billiard works as before, but there is also interaction in the boundary map: clicking on it will generate a particle whose boundary map is the clicked point.

The mean collision time "m.c.t." of the particle is shown as well.

Keywords

  • newcolor = randomcolor A function which takes as input (pos, vel, ξ, sφ) and outputs a color (for the scatter points in the boundary map).
  • ms = 12 markersize (in pixels).
  • dt, tail, sleept, fade : propagated to interactive_billiard.
source

InteractiveChaos.billiard_bmap_plotFunction
billiard_bmap_plot(bd::Billiard, ps::Vector{<:AbstractParticle}; kwargs...)

Return a static scene which has particles plotted on both the real billiard as well the boundary map, each with its own color (keyword colors), and the same color is used for the corresponding scatter points in the boundary map.

All keyword arguments are the same as interactive_billiard_bmap, besides the interaction part of course.

source