Imager::Matrix2d - simple wrapper for matrix construction
use Imager::Matrix2d; $m1 = Imager::Matrix2d->identity; $m2 = Imager::Matrix2d->rotate(radians=>$angle, x=>$cx, y=>$cy); $m3 = Imager::Matrix2d->translate(x=>$dx, y=>$dy); $m4 = Imager::Matrix2d->shear(x=>$sx, y=>$sy); $m5 = Imager::Matrix2d->reflect(axis=>$axis); $m6 = Imager::Matrix2d->scale(x=>$xratio, y=>$yratio); $m8 = Imager::Matric2d->matrix($v11, $v12, $v13, $v21, $v22, $v23, $v31, $v32, $v33); $m6 = $m1 * $m2; $m7 = $m1 + $m2; use Imager::Matrix2d qw(:handy); # various m2d_* functions imported # where m2d_(.*) calls Imager::Matrix2d->$1()
This class provides a simple wrapper around a reference to an array of 9 co-efficients, treated as a matrix:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
Most of the methods in this class are constructors. The others are overloaded operators.
Note that since Imager represents images with y increasing from top to bottom, rotation angles are clockwise, rather than counter-clockwise.
Returns the identity matrix.
Creates a matrix that rotates around the origin, or around the point (x,y) if the 'x' and 'y' parameters are provided.
Translates by the specify amounts.
Shear by the given amounts.
Reflect around the given axis, either 'x' or 'y'.
Reflect around a line drawn at the given angle from the origin.
Scales at the given ratios.
You can also specify a center for the scaling with the
Create a matrix with custom co-efficients.
Implements the overloaded '*' operator. Internal use.
Currently both the left and right-hand sides of the operator must be an Imager::Matrix2d.
Implements the overloaded binary '+' operator.
Currently both the left and right sides of the operator must be Imager::Matrix2d objects.
Implements the overloaded stringification operator.
This returns a string containing 3 lines of text with no terminating newline.
I tried to make it fairly nicely formatted. You might disagree :)
Implement the overloaded equality operator.
Provided for older perls that don't handle magic auto generation of eq from "".
The following functions are shortcuts to the various constructors.
These are not methods.
You can import these methods with:
use Imager::Matrix2d ':handy';
Tony Cook <email@example.com>
Needs a way to invert a matrix.