NAME
Physics::Balls::Tick - one advance to a horizon, for a game that ticks
VERSION
Version 0.08
SYNOPSIS
my $tick = Physics::Balls::Tick->new(t => 20000);
my $out = $tick->play($world, [ [0, 50000, 100000, 0, 0, 300000], [1, 50000, 5000, 1, 0, 0] ]);
my $rows = $out->state; # [[id, x, y, vx, vy, mode], ...] at the horizon
DESCRIPTION
A strike releases one ball and runs until everything rests. A live game cannot wait for that: it ticks, sets what it drives (a mallet, a paddle) to a velocity of its own each tick, and needs every body's position and velocity exactly one tick later. This is that call, since 0.07: every row may carry a starting velocity, in hundredths of a millimetre a second, the world is advanced exactly t microseconds, and the outcome's state holds every body at the horizon. Integers throughout, so a tick's state is the next tick's row and every encoder spells it the same way.
A body with a velocity is released rolling, with its roll equal to its velocity, and no speed floor applies. An event at exactly the horizon belongs to the next call. The settle pass runs at the horizon as it does at rest. A kind's follow of 0 keeps the roll equal to the velocity through every contact, and a world with rc 1 and cf 0 keeps it so off a cushion, which is what makes [x, y, vx, vy] the whole state to carry.
ATTRIBUTES
t
The horizon in microseconds, an integer from 1 to 40,000,000; default 20000.
trace
When true the outcome carries the energy after every event.
METHODS
validate
my $err = $tick->validate($world, \@layout);
Undef when the layout is acceptable, else the Physics::Balls::Error: rows of six integers with distinct ids and kinds the world declares, velocities within plus or minus 100,000,000 (1000 m/s), no two bodies more than a tenth of a millimetre inside each other, and a horizon in range.
rows
The layout as plain rows, whatever it was given as.
play
my $out = $tick->play($world, \@layout);
A Physics::Balls::Outcome with state filled, or the error that refused it.