… | |
… | |
2 | |
2 | |
3 | sub _parserImplicitPlane_init {}; # don't reload this file |
3 | sub _parserImplicitPlane_init {}; # don't reload this file |
4 | |
4 | |
5 | =head1 DESCRIPTION |
5 | =head1 DESCRIPTION |
6 | |
6 | |
7 | ###################################################################### |
7 | ###################################################################### |
8 | # |
8 | # |
9 | # This is a Parser class that implements implicit planes as |
9 | # This is a Parser class that implements implicit planes as |
10 | # a subclass of the Formula class. The standard ->cmp routine |
10 | # a subclass of the Formula class. The standard ->cmp routine |
11 | # will work for this, provided we define the compare() function |
11 | # will work for this, provided we define the compare() function |
12 | # needed by the overloaded ==. We assign the special precedence |
12 | # needed by the overloaded ==. We assign the special precedence |
13 | # so that overloaded operations will be promoted to the ones below. |
13 | # so that overloaded operations will be promoted to the ones below. |
14 | # |
14 | # |
15 | # |
15 | # |
16 | # Use ImplicitPlane(point,vector), ImplicitPlane(point,number) or |
16 | # Use ImplicitPlane(point,vector), ImplicitPlane(point,number) or |
17 | # ImplicitPlane(formula) to create an ImplicitPlane object. |
17 | # ImplicitPlane(formula) to create an ImplicitPlane object. |
18 | # The first form uses the point as a point on the plane and the |
18 | # The first form uses the point as a point on the plane and the |
19 | # vector as the normal for the plane. The second form uses the point |
19 | # vector as the normal for the plane. The second form uses the point |
20 | # as the coefficients of the variables and the number as the value |
20 | # as the coefficients of the variables and the number as the value |
21 | # that the formula must equal. The third form uses the formula |
21 | # that the formula must equal. The third form uses the formula |
22 | # directly. |
22 | # directly. |
23 | # |
23 | # |
24 | # The number of variables in the Context determines the dimension of |
24 | # The number of variables in the Context determines the dimension of |
25 | # the "plane" being defined. If there are only two, the formula |
25 | # the "plane" being defined. If there are only two, the formula |
26 | # produces an implicit line, but if there are four variables, it will |
26 | # produces an implicit line, but if there are four variables, it will |
27 | # be a hyperplane in four-space. You can specify the variables you |
27 | # be a hyperplane in four-space. You can specify the variables you |
28 | # want to use by supplying an additional parameter, which is a |
28 | # want to use by supplying an additional parameter, which is a |
29 | # reference to an array of variable names. |
29 | # reference to an array of variable names. |
30 | # |
30 | # |
31 | # |
31 | # |
32 | # Usage examples: |
32 | # Usage examples: |
33 | # |
33 | # |
34 | # $P = ImplicitPlane(Point(1,0,2),Vector(-1,1,3)); # -x+y+3z = 5 |
34 | # $P = ImplicitPlane(Point(1,0,2),Vector(-1,1,3)); # -x+y+3z = 5 |
35 | # $P = ImplicitPlane([1,0,2],[-1,1,3]); # -x+y+3z = 5 |
35 | # $P = ImplicitPlane([1,0,2],[-1,1,3]); # -x+y+3z = 5 |
36 | # $P = ImplicitPlane([1,0,2],4); # x+2z = 4 |
36 | # $P = ImplicitPlane([1,0,2],4); # x+2z = 4 |
37 | # $P = ImplicitPlane("x+2y-z=5"); |
37 | # $P = ImplicitPlane("x+2y-z=5"); |
38 | # |
38 | # |
39 | # Context()->variables->are(x=>'Real',y=>'Real',z=>'Real',w=>'Real'); |
39 | # Context()->variables->are(x=>'Real',y=>'Real',z=>'Real',w=>'Real'); |
40 | # $P = ImplicitPlane([1,0,2,-1],10); # w+2y-z = 10 (alphabetical order) |
40 | # $P = ImplicitPlane([1,0,2,-1],10); # w+2y-z = 10 (alphabetical order) |
41 | # $P = ImplicitPlane([3,-1,2,4],5,['x','y','z','w']); # 3x-y+2z+4w = 5 |
41 | # $P = ImplicitPlane([3,-1,2,4],5,['x','y','z','w']); # 3x-y+2z+4w = 5 |
42 | # $P = ImplicitPlane([3,-1,2],5,['y','z','w']); # 3y-z+2w = 5 |
42 | # $P = ImplicitPlane([3,-1,2],5,['y','z','w']); # 3y-z+2w = 5 |
43 | # |
43 | # |
44 | # Then use |
44 | # Then use |
45 | # |
45 | # |
46 | # ANS($P->cmp); |
46 | # ANS($P->cmp); |
47 | # |
47 | # |
48 | # to get the answer checker for $P. |
48 | # to get the answer checker for $P. |
49 | # |
49 | # |
50 | |
50 | |
51 | =cut |
51 | =cut |
52 | |
52 | |
53 | # |
53 | # |
54 | # Create a context for implicit planes and activate it |
54 | # Create a context for implicit planes and activate it |