@@ -86,18 +86,6 @@ $gt = GraphTool("{circle, solid, ($h, $k), ($h + $r, $k)}")->with(
86
86
my @errors;
87
87
my $count = 1;
88
88
89
- # Get the center and point that define the correct circle and
90
- # compute the square of the radius.
91
- my ($cx, $cy) = $correct->[0]->extract(3)->value;
92
- my ($px, $py) = $correct->[0]->extract(4)->value;
93
- my $r_squared = ($cx - $px)**2 + ($cy - $py)**2;
94
-
95
- my $pointOnCircle = sub {
96
- my $point = shift;
97
- my ($x, $y) = $point->value;
98
- return ($x - $cx)**2 + ($y - $cy)**2 == $r_squared;
99
- };
100
-
101
89
# Iterate through the objects the student graphed and check to
102
90
# see if each is the correct circle.
103
91
for (@$student) {
@@ -107,12 +95,8 @@ $gt = GraphTool("{circle, solid, ($h, $k), ($h + $r, $k)}")->with(
107
95
# type as the correct object type (a circle in this case),
108
96
# has the same solid or dashed status, has the same center, and
109
97
# if the other point graphed is on the circle.
110
- if ($_->extract(1) eq $correct->[0]->extract(1)
111
- && $_->extract(2) eq $correct->[0]->extract(2)
112
- && $_->extract(3) == $correct->[0]->extract(3)
113
- && $pointOnCircle->($_->extract(4)))
114
- {
115
- $score += 1;
98
+ if ($correct->[0] == $_) {
99
+ ++$score;
116
100
next;
117
101
}
118
102
@@ -124,7 +108,13 @@ $gt = GraphTool("{circle, solid, ($h, $k), ($h + $r, $k)}")->with(
124
108
next;
125
109
}
126
110
127
- if ($_->extract(2) ne $correct->[0]->extract(2)) {
111
+ # Calling $correct->[0]->cmp($_, 1) does a "fuzzy" comparison.
112
+ # This is the same as $correct->[0] == $_ except that it ignores
113
+ # the solid or dashed status and only checks the center point
114
+ # and radius, i.e., that the circles are the same.
115
+ if ($correct->[0]->cmp($_, 1)
116
+ && $_->extract(2) ne $correct->[0]->extract(2))
117
+ {
128
118
push(@errors,
129
119
"The $nth object graphed should be a "
130
120
. $correct->[0]->extract(2)
0 commit comments