NAME
Physics::Balls::Outcome - what a strike did
VERSION
Version 0.01
SYNOPSIS
my $out = $strike->play($world, \@layout);
my $first = $out->first(0); # the ball the cue ball met first, or undef
my @pots = @{ $out->holed }; # [id, pocket, t] in time order
my $rest = $out->rest; # [id, x, y] for every ball in play
my $segs = $out->segments->{0}; # the cue ball's trajectory, segment by segment
DESCRIPTION
The record of one shot. events is every event in time order as [t, kind, a, b]: roll and stop for one ball, ball for two, wall and nose with the wall or nose index, pot with the pocket number. A rules module reads first contact, cushions after contact and pots in order straight off it. segments is the trajectory a client plays back, per ball id, each [t0, dur, px, py, vx, vy, ax, ay] in metres and seconds, so a position at time t within a segment is p0 + v (t - t0) + a (t - t0)^2 / 2.
ATTRIBUTES
t
Simulated seconds until the last ball stopped.
n
Events processed.
error
Undef, or events or time when the engine gave up; an outcome with an error is still returned so a caller can see how far it got.
events
rest
holed
segments
energy
Per unit mass after the strike and after every event, when the strike was traced; else empty.
shot
The shot that produced this.
METHODS
message
A sentence for error, or the empty string.
first
my $other = $out->first($id);
The first ball $id met, or undef when it met a wall, a nose or a pocket first or nothing at all.
walls_touched
The wall and nose events for a ball.
potted
my $h = $out->potted($id);
The [id, pocket, t] row, or undef.
contacts
The events that are contacts, without the roll and stop transitions.
to_payload
The hash a game stores and a client plays back: engine, t, n, error, events, rest, holed, segments.