NAME

Physics::Balls::Ball - one ball's place in a layout

VERSION

Version 0.06

SYNOPSIS

my $ball = Physics::Balls::Ball->new(id => 3, x => 190500, y => 63500);
my ($x, $y) = $ball->metres;
my $row = $ball->row;     # [3, 190500, 63500], what a layout holds

my $bowl = Physics::Balls::Ball->new(id => 4, x => 0, y => 200000, kind => 1);
$bowl->row;               # [4, 0, 200000, 1]: a ball of the world's kind 1

DESCRIPTION

A layout is a list of [id, x, y] rows in hundredths of a millimetre, or [id, x, y, kind] when the ball is of a kind the world declares; this is the row as an object for a caller that wants one. The engine takes rows or these interchangeably.

METHODS

id

x

y

Integers, hundredths of a millimetre.

kind

An integer index into the world's kinds, default 0. A world that declares no kinds has only kind 0, a ball that never curves.

from_metres

my $ball = Physics::Balls::Ball->from_metres(3, 1.905, 0.635);
my $bowl = Physics::Balls::Ball->from_metres(4, 0, 2, 1);

Rounds to the nearest hundredth.

metres

The position as two doubles.

row

The [id, x, y] row, with the kind as a fourth element when it is not 0, so a layout of ordinary balls is spelled as it always was.