NAME

Math::Shape::Rectangle - a 2d rectangle in cartesian space

VERSION

version 0.03

SYNOPSIS

use Math::Shape::Rectangle;
use Math::Trig;

my $r = Math::Shape::Rectangle->new(1,1,0,2,2);

$r->rotate(pi);
Coverage Status

METHODS

new

Creates a new Math::Shape::Rectangle object. Requires 5 arguments: the x, y coordinates of the centre, the radius for the direction, and the length and width args.

Math::Shape::Rectangle->new(1,1,0,2,2);

rotate

Requires a numerical argument in radians and turns the rectangle. Negative numbers rotate left and positive numbers rotate right.

use Math::Trig ':pi';
$rectangle->rotate(pip2); # turn half pi radians (90 degrees) right;
$rectangle->rotate(-pi); # turn pi radians (180 degrees) left;

get_points

Returns hashref of points.

detect_collision

Requires another Math::Shape::Rectangle object and returns true if their coordinates overlap or false if they do not.

test_radius_intersect

Requires another Math::Shape::Rectangle object and returns true if the distance between them is less than their radius.

INTERNAL METHODS

_calculate_corners

Creates the 4 point objects that represent the corners of the rectangle.

REPOSITORY

https://github.com/sillymoose/Math-Shape-Rectangle.git

AUTHOR

David Farrell <sillymoos@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by David Farrell.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.