Difference between revisions of "Aiming"

From CodeStuff
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
  
 
<edcode>
 
<edcode>
 +
 
var t=0.0;
 
var t=0.0;
 
var speed=0.02;
 
var speed=0.02;
Line 104: Line 105:
 
   drawLine(ax,ay,bx,by);   
 
   drawLine(ax,ay,bx,by);   
 
    
 
    
   annotation="Adding the straight line to the target makes a right angled triangle";
+
   annotation="The straight line to the target makes a right angled triangle";
  
 
   triangleNote();   
 
   triangleNote();   
Line 128: Line 129:
 
   vector(transition(0,30));
 
   vector(transition(0,30));
 
   annotation="We want to move a fixed distance along this line";
 
   annotation="We want to move a fixed distance along this line";
   dataNote+=", we want to move a distance of 30";
+
   dataNote+=". We want to move 30";
 
}
 
}
  
Line 140: Line 141:
 
   speed=0.003;
 
   speed=0.003;
 
   loop();
 
   loop();
   annotation="When the points are different the move distance should stay the same";
+
   annotation="The movement distance should always be the same ";
   dataNote+=", the move distance we want is 30";
+
   dataNote+=". We want to move 30 ";
 
}
 
}
  
Line 147: Line 148:
 
   triangle();
 
   triangle();
 
   vector(30);
 
   vector(30);
   annotation="To find x and y movement we reduce both values by the same amount";
+
   annotation="To find our movement we scale all values by the same amount";
   dataNote+=", the move distance we want is 30";
+
   dataNote+=". We want to move 30";
 
}
 
}
  
Line 171: Line 172:
 
   speed=0.001;
 
   speed=0.001;
  
   annotation="The angles stay the same if the sides are divided by the same amount";
+
   annotation="The angles stay the same when all sides are scaled evenly";
 
   triangleNote();   
 
   triangleNote();   
   dataNote+=", the move distance we want is 30";
+
   dataNote+=". We want to move 30";
  
 
   var newdx=dx*scale;
 
   var newdx=dx*scale;
Line 209: Line 210:
 
   if (part+1<parts.length ) {
 
   if (part+1<parts.length ) {
 
     setColour("black");
 
     setColour("black");
     print("Pres Space to continue.",220,470);
+
     print("Press Space to continue.",220,470);
  
 
   }
 
   }
Line 230: Line 231:
  
 
run(update);
 
run(update);
 +
 +
  
 
</edcode>
 
</edcode>

Latest revision as of 20:53, 27 June 2017

Run this program to see an animated diagram shoing how to find a direction towards another point.