Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub extract_crossing {
- my @x = @{ $_[0] }; my @y = @{ $_[1] };
- my @xcross =(); my @ycross =();
- for (my $i=0; $i<$#x; $i++) {
- my $k = ($y[$i] - $y[$i+1]) / ($x[$i] - $x[$i+1]);
- if($y[$i+1] * $y[$i] < 0) {
- my $xc = $x[$i+1] - $y[$i+1] / $k;
- push(@xcross, $xc);
- }
- if($x[$i+1] * $x[$i] < 0) {
- my $yc = $y[$i+1] - $x[$i+1] * $k;
- push(@ycross, $yc);
- }
- }
- return (@xcross, @ycross);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement