NAME
Math::Shape::OrientedRectangle - a 2d oriented rectangle
VERSION
version 0.15
METHODS
new
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
get_edge
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);
axis_is_separating
Boolean method that returns 1 if the axis is separating. Requires a Math::Shape::LineSegment object (for the axis) as an argment.
corner
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);
hull
Returns a Math::Shape::Rectangle object representing the hull of the oriented rectangle.
circle_hull
Returns a new Math::Shape::Circle object representing the hull of the oriented rectangle.
collides
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))
{
...
}
AUTHOR
David Farrell <dfarrell@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2015 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.