| … | |
… | |
| 2 | |
2 | |
| 3 | ################################################################ |
3 | ################################################################ |
| 4 | # subroutines |
4 | # subroutines |
| 5 | ################################################################ |
5 | ################################################################ |
| 6 | |
6 | |
|
|
7 | =head1 NAME |
|
|
8 | |
|
|
9 | PGanalyzeGraph.pl |
|
|
10 | |
|
|
11 | =head1 DESCRIPTION |
|
|
12 | |
|
|
13 | These routines support the |
|
|
14 | analysis of graphical input from students. |
|
|
15 | |
|
|
16 | =cut |
| 7 | |
17 | |
| 8 | |
18 | |
| 9 | =head4 detect_intervals |
19 | =head4 detect_intervals |
| 10 | |
20 | |
|
|
21 | |
|
|
22 | |
| 11 | input: $pointDisplayString |
23 | input: $pointDisplayString |
| 12 | return delimited string of triplets |
24 | |
| 13 | each triplet has the form x y yp (space delimited) |
|
|
| 14 | giving the x, y and y'(x) values at x respectively |
|
|
| 15 | return: (\@combined_intervals, \@values) |
25 | return: (\@combined_intervals, \@values) |
| 16 | @values contains the y values of the function in order |
26 | @values contains the y values of the function in order |
| 17 | @combined_intervals contains anonymous arrays of the form |
27 | @combined_intervals contains anonymous arrays of the form |
| 18 | [ $slope, $left_x, $right_x] indicating the gradient on that segment. |
28 | [ $slope, $left_x, $right_x] indicating the gradient on that segment. |
| 19 | successive intervals will have different slopes. |
29 | successive intervals will have different slopes. |
| 20 | |
30 | |
| 21 | |
31 | |
| 22 | =cut |
32 | =cut |
| 23 | |
33 | |
|
|
34 | |
|
|
35 | |
| 24 | sub detect_intervals { |
36 | sub detect_intervals { |
| 25 | my $pointDisplayString = shift; |
37 | my $pointDisplayString = shift; |
| 26 | my @intervals; |
38 | my @intervals; |
| 27 | my @combined_intervals=(); |
39 | my @combined_intervals=(); |
| 28 | my @points; |
40 | my @points; |