Math::Shape::OrientedRectangle - a 2d oriented rectangle
version 0.12
Constructor, requires 5 values: the x,y values for the center and the x,y values for the half_extend vector and a rotation number.
my $OrientedRectangle = Math::Shape::OrientedRectangle->new(1, 1, 2, 4, 45); my $width = $OrientedRectangle->{rotation}; # 45
Returns a Math::Shape::LineSegment object for a given edge of the rectangle. Requires a number for the edge of the rectangle to return (0-3).
my $segment= $oriented_rectangle->get_edge(1);
Boolean method that returns 1 if the axis is separating. Requires a Math::Shape::LineSegment object (for the axis) as an argment.
Returns a Math::Shape::Vector object representing a corner of the rectangle. Requires a number between 0-3 for the corner.
my $corner = $OrientedRectangle->corner(2);
Returns a Math::Shape::Rectangle object representing the hull of the oriented rectangle.
Returns a new Math::Shape::Circle object representing the hull of the oriented rectangle.
Boolean method returns 1 if the OrientedRectangle collides with another Math::Shape::Vector library object, else returns 0. Requires a Math::Shape::Vector library object as an argument.
if($OrientedRectangle->collides($other_OrientedRectangle)) { ... }
David Farrell <sillymoos@cpan.org>
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.
To install Math::Shape::Vector, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::Shape::Vector
CPAN shell
perl -MCPAN -e shell install Math::Shape::Vector
For more information on module installation, please visit the detailed CPAN module installation guide.