[system] / trunk / pg / macros / parserParametricLine.pl Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# Diff of /trunk/pg/macros/parserParametricLine.pl

Revision 2728 Revision 2934
42# 42#
43\$context{ParametricLine} = Context("Vector")->copy(); 43\$context{ParametricLine} = Context("Vector")->copy();
44\$context{ParametricLine}->variables->are(t=>'Real'); 44\$context{ParametricLine}->variables->are(t=>'Real');
45\$context{ParametricLine}->{precedence}{ParametricLine} = 45\$context{ParametricLine}->{precedence}{ParametricLine} =
46 \$context{ParametricLine}->{precedence}{special}; 46 \$context{ParametricLine}->{precedence}{special};
47\$context{ParametricLine}->reduction->set('(-x)-y'=>0);
47# 48#
48# Make it active 49# Make it active
49# 50#
50Context("ParametricLine"); 51Context("ParametricLine");
51 52
74 } else { 75 } else {
75 \$line = Value::Formula->new(shift); 76 \$line = Value::Formula->new(shift);
76 Value::Error("Your formula doesn't look like a parametric line") 77 Value::Error("Your formula doesn't look like a parametric line")
77 unless \$line->type eq 'Vector'; 78 unless \$line->type eq 'Vector';
78 \$t = shift || (keys %{\$line->{variables}})[0]; 79 \$t = shift || (keys %{\$line->{variables}})[0];
80 Value::Error("A line can't be just a constant vector") unless \$t;
79 \$p = Value::Point->new(\$line->eval(\$t=>0)); 81 \$p = Value::Point->new(\$line->eval(\$t=>0));
80 \$v = \$line->eval(\$t=>1) - \$p; 82 \$v = Value::Vector->new(\$line->eval(\$t=>1) - \$p);
81 Value::Error("Your formula isn't linear in the variable \$t") 83 Value::Error("Your formula isn't linear in the variable \$t")
82 unless \$line == \$p + Value::Formula->new(\$t) * \$v; 84 unless \$line == \$p + Value::Formula->new(\$t) * \$v;
83 } 85 }
84 Value::Error("The direction vector for a parametric line can't be the zero vector") 86 Value::Error("The direction vector for a parametric line can't be the zero vector")
85 if (\$v->norm == 0); 87 if (\$v->norm == 0);
116# 118#
117# Report some errors that were stopped by the showEqualErrors=>0 above. 119# Report some errors that were stopped by the showEqualErrors=>0 above.
118# 120#
119sub cmp_postprocess { 121sub cmp_postprocess {
120 my \$self = shift; my \$ans = shift; 122 my \$self = shift; my \$ans = shift;
123 my \$error = \$\$Value::context->{error}{message};
121 \$self->cmp_error(\$ans) 124 \$self->cmp_error(\$ans)
122 if \$\$Value::context->{error}{message} =~ m/^Your formula isn't linear/; 125 if \$error =~ m/^(Your formula (isn't linear|doesn't look)|A line can't|The direction vector)/;
123} 126}
124 127
1251; 1281;

Legend:
 Removed from v.2728 changed lines Added in v.2934