[LON-CAPA-cvs] cvs: loncom /homework functionplotresponse.pm
www
www at source.lon-capa.org
Sat Nov 19 19:34:52 EST 2011
www Sun Nov 20 00:34:52 2011 EDT
Modified files:
/loncom/homework functionplotresponse.pm
Log:
Vector lengths and angles
Index: loncom/homework/functionplotresponse.pm
diff -u loncom/homework/functionplotresponse.pm:1.77 loncom/homework/functionplotresponse.pm:1.78
--- loncom/homework/functionplotresponse.pm:1.77 Sat Nov 19 23:35:25 2011
+++ loncom/homework/functionplotresponse.pm Sun Nov 20 00:34:52 2011
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# Functionplot responses
#
-# $Id: functionplotresponse.pm,v 1.77 2011/11/19 23:35:25 www Exp $
+# $Id: functionplotresponse.pm,v 1.78 2011/11/20 00:34:52 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1388,6 +1388,9 @@
sub vectorangle {
my ($x,$y)=@_;
+ my $angle=57.2957795*atan2($y,$x);
+ if ($angle<0) { $angle=360+$angle; }
+ return $angle;
}
sub vectorlength {
@@ -1395,6 +1398,19 @@
return sqrt($x*$x+$y*$y);
}
+sub relvector {
+ my ($xs,$xe,$ys,$ye)=@_;
+ return ($xe-$xs,$ye-$ys);
+}
+
+sub plotvectorlength {
+ return &vectorlength(&relvector(&vectorcoords(@_)));
+}
+
+sub plotvectorangle {
+ return &vectorangle(&relvector(&vectorcoords(@_)));
+}
+
#
# Evaluate a functionplotvectorrule
@@ -1402,6 +1418,7 @@
sub functionplotvectorrulecheck {
my ($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)=@_;
+ &addlog("=================");
my ($label,$type)=split(/\:/,$rule);
if ($type eq 'vector') {
return &vectorcheck($rule,$xmin,$xmax,$ymin,$ymax,$safeeval);
@@ -1416,11 +1433,14 @@
$attachpoint,$notattachpoint,
$tailpoint,$tippoint,$nottailpoint,$nottippoint,
$length,$angle,$lengthpercenterror,$anglepercenterror)=split(/\:/,$rule);
+ &addlog("Vector Rule $label for vector ".$vector);
+
}
sub sumcheck {
my ($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)=@_;
my ($label,$type,$id,$object,$length,$angle,$lengthpercenterror,$lengthabserror,$anglepercenterror)=split(/\:/,$rule);
+ &addlog("Vector Sum Rule $label for vectors attached to ".$object);
}
#
More information about the LON-CAPA-cvs
mailing list