version 1.81, 2011/11/21 19:48:52
|
version 1.82, 2011/11/21 20:20:48
|
Line 894 sub start_functionplotvectorsumrule {
|
Line 894 sub start_functionplotvectorsumrule {
|
my $id=$Apache::inputtags::response[-1]; |
my $id=$Apache::inputtags::response[-1]; |
my $partid=$Apache::inputtags::part; |
my $partid=$Apache::inputtags::part; |
my $internalid = $partid.'_'.$id; |
my $internalid = $partid.'_'.$id; |
my $object=&Apache::lonxml::get_param('object',$parstack,$safeeval); |
my $vectors=&Apache::lonxml::get_param('vectors',$parstack,$safeeval); |
$object=~s/\W//gs; |
|
$object=ucfirst($object); |
|
push(@Apache::functionplotresponse::functionplotvectorrules,join(':',( |
push(@Apache::functionplotresponse::functionplotvectorrules,join(':',( |
$label, |
$label, |
'sum', |
'sum', |
$internalid, |
$internalid, |
$object, |
$vectors, |
&Apache::lonxml::get_param('length',$parstack,$safeeval), |
&Apache::lonxml::get_param('length',$parstack,$safeeval), |
&Apache::lonxml::get_param('angle',$parstack,$safeeval), |
&Apache::lonxml::get_param('angle',$parstack,$safeeval), |
&Apache::lonxml::get_param('lengtherror',$parstack,$safeeval), |
&Apache::lonxml::get_param('lengtherror',$parstack,$safeeval), |
Line 911 sub start_functionplotvectorsumrule {
|
Line 909 sub start_functionplotvectorsumrule {
|
$result=&Apache::edit::tag_start($target,$token,'Function Plot Vector Sum Rule'). |
$result=&Apache::edit::tag_start($target,$token,'Function Plot Vector Sum Rule'). |
&Apache::edit::text_arg('Index/Name:','index', |
&Apache::edit::text_arg('Index/Name:','index', |
$token,'10').' '. |
$token,'10').' '. |
&Apache::edit::text_arg('Vectors attached to object:','object', |
&Apache::edit::text_arg('Comma-separated list of vectors:','vectors', |
$token,'16').'<br />'. |
$token,'30').'<br />'. |
&Apache::edit::text_arg('Sum vector length:','length', |
&Apache::edit::text_arg('Sum vector length:','length', |
$token,'16'). |
$token,'16'). |
&Apache::edit::text_arg('Sum vector angle:','angle', |
&Apache::edit::text_arg('Sum vector angle:','angle', |
Line 925 sub start_functionplotvectorsumrule {
|
Line 923 sub start_functionplotvectorsumrule {
|
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
$env{'form.'.&Apache::edit::html_element_name('object')}=ucfirst($env{'form.'.&Apache::edit::html_element_name('object')}); |
$env{'form.'.&Apache::edit::html_element_name('object')}=ucfirst($env{'form.'.&Apache::edit::html_element_name('object')}); |
my $constructtag=&Apache::edit::get_new_args($token,$parstack, |
my $constructtag=&Apache::edit::get_new_args($token,$parstack, |
$safeeval,'index','object', |
$safeeval,'index','vectors', |
'length','angle', |
'length','angle', |
,'lengtherror','angleerror'); |
,'lengtherror','angleerror'); |
if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); } |
if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); } |
Line 1520 sub vectorcheck {
|
Line 1518 sub vectorcheck {
|
|
|
sub sumcheck { |
sub sumcheck { |
my ($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)=@_; |
my ($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)=@_; |
my ($label,$type,$id,$object,$length,$angle,$lengtherror,$angleerror)=split(/\:/,$rule); |
my ($label,$type,$id,$vectors,$length,$angle,$lengtherror,$angleerror)=split(/\:/,$rule); |
&addlog("Vector Sum Rule $label for vectors attached to ".$object); |
&addlog("Vector Sum Rule $label for vectors ".$vectors); |
|
my $sumx=0; |
|
my $sumy=0; |
|
foreach my $sv (split(/\s*\,\s*/,$vectors)) { |
|
my ($rx,$ry)=&relvector(&vectorcoords($id,$sv)); |
|
$sumx+=$rx; |
|
$sumy+=$ry; |
|
} |
|
&addlog("Sum vector ($sumx,$sumy)"); |
&addlog("Rule $label passed."); |
&addlog("Rule $label passed."); |
return 1; |
return 1; |
} |
} |