sub rotate { my ($x, $y, $r) = @_; my ($s, $c) = (sin($r), cos($r)); return ($c*$x - $s*$y, $s*$x + $c*$y); }