NAME

Graphics::Penplotter::GcodeXY::Geometry2D - Geometric primitives and transformations for GcodeXY

SYNOPSIS

$g->moveto(10, 20);
$g->line(30, 40);
$g->circle(50, 50, 10);
$g->rotate(45);
$g->arc(0, 0, 5, 0, 180);

DESCRIPTION

A Role::Tiny role providing all geometric drawing primitives, coordinate-system transformations, and clipping routines for Graphics::Penplotter::GcodeXY.

Coordinate spaces

Three coordinate spaces are used:

User space

The result of scaling, rotation, and translation applied by the caller. Methods such as translate, rotate, and scale manipulate the Current Transformation Matrix (CTM) that maps user to paper space.

Paper space

Absolute position on the page. Found by applying the CTM to user coordinates.

Device space

Physical inches. Found by multiplying paper coordinates by dscale.

METHODS

All the public drawing methods (moveto, line, polygon, box, curve, arc, circle, ellipse, rotate, translate, scale, etc.) as well as the graphics-state methods gsave and grestore are provided by this role.

The line-clipping functions _getsegintersect (Cramer's Rule) and _LiangBarsky (Liang-Barsky rectangle clipping) are also included here since they are pure geometric computations.

REQUIRED METHODS

This role requires the consuming class to provide: penup, pendown, _genfastmove, _genslowmove, stroke, _croak, _penlock, _penunlock.

AUTHOR

Albert Koelmans (albert.koelmans@googlemail.com)

LICENSE

Same terms as Perl itself.