Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my @rect1 = ([1, 3], [3, 3], [3, 1], [1, 1]);
- my @rect2 = ([3, 5], [5, 5], [5, 3], [3, 3]);
- sub check_rect_intersection {
- my @rect1 = @_[0..3];
- my @rect2 = @_[4..7];
- sub rect_bounds {
- my @rect = @_;
- my @res;
- for my $axis (0,1) {
- my $max;
- my $min;
- for my $point (@rect) {
- if (!defined $max || $max < $point->[$axis]) {
- $max = $point->[$axis];
- }
- if (!defined $min || $min > $point->[$axis]) {
- $min = $point->[$axis];
- }
- }
- $res[$axis]
- }
- }
- my @bounds = (rect_bounds(@rect1), rect_bounds(@rect2);
- }
- check_rect_intersection(@rect1, @rect2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement