![]() |
| https://iwant2study.org/ospsg/index.php/interactive-resources/mathematics/measurement-and-geometry/measurement/2-time/425-clockgeogebrawee direct link |
Telling Time to one and half hour for Primary 1 only JavaScript HTML5 Applet Simulation Model
On the drag of the hour hand.
Techniques use
- console.log(), to see every moment what is the values of the variable
- alert(), to pause the sim at point of code if and else if
- variables test and test1, test variables to display values
- variables detect and detecth, test variables to display values, try to be unique and don't recycle variables
//three lines to restrict drag to circle path
//_info.point
ctah = Math.atan2(_info.point[0],_info.point[1]);
var hxtest = 2.5*Math.sin(ctah); //new position angles
var hytest =2.5*Math.cos(ctah);
//ctah = Math.atan2(hx,hy);
//hx=2.5*Math.sin(ctah); //lookang cannot use Rs variable
//hy=2.5*Math.cos(ctah);
var vh24hourformat = vh;
//vs = Math.round(60/pi2*Math.atan2(sx,sy));
//vh = 12/pi2*Math.atan2(hx,hy); //assign coordinates sx sy to vs
vhtest = 12/pi2*Math.atan2(hxtest,hytest); //resolve to minute value based on mouse
//am
if (vhtest <0&&vh24hourformat<12) { // 31 to 59 sec are return back as -29 and -1
vhtest = vhtest+12; // clever way to assign 31 to 59 sec
test=2
}
else if (vhtest >0&&vh24hourformat<12) { // 31 to 59 sec are return back as -29 and -1
vhtest = vhtest; // clever way to assign 31 to 59 sec
test=1
}
//pm
else if (vhtest >0&&vh24hourformat>12) { // 31 to 59 sec are return back as -29 and -1
vhtest = vhtest+12; // clever way to assign 31 to 59 sec
test=3
}
else if (vhtest <0&&vh24hourformat>17) { // cannot 18 didnt hit quadrant correctly
vhtest = vhtest+12+12; // clever way to assign 31 to 59 sec
test =4
}
console.log(("vh "+vh ))
console.log(("difference= "+(vhtest-vh) ))
//
var diff = 0.01
var jumpdiff = 11
// cross to the right 1200
//if ((vhtest-vh)>jumpdiff&&Math.ceil(vh)==0){ //postive direction example pass 12 to the left
if ((vhtest-vh)<-jumpdiff&&Math.round(vh)==12){ //postive direction example pass 12 to the left
detecth=1;
t = vhtest*60*60+ detecth*3600*12
test1 =1
//alert(test1)
}
// cross to the left 0000
else if ((vhtest-vh)>jumpdiff&&Math.round(vh)==0){ //postive direction example pass 12 to the left
detecth=1;
t = vhtest*60*60+ detecth*3600*12
test1 =2
// alert(test1)
}
//cross left 1200
//else if ((vhtest-vh)>diff&&Math.round(vh)==24){ //negative direction example pass 12 to the right
// detecth=-1;
//t = vhtest*60*60+ detecth*3600*24
//test1 =3
// alert(test1)
// }
// cross to the right 2359
else if ((vhtest-vh)<-jumpdiff&&Math.round(vh)==24){ //negative direction example pass 12 to the right
detecth=-1;
t = vhtest*60*60+ detecth*3600*24
test1 =4
// alert(test1)
}
else {
detecth=0;
test1 =0
t = vhtest*60*60
}
console.log(("test1= "+test1 ))
//assign t back with new values of vs
//t = vs+vm*60+vh*60*60;
//if (vh24hourformat > 12){ // for pm
// t = vh*60*60+ 12*60*60 //+ detecth*3600*12;
//}
//else { // for am
// t = vhtest*60*60 + detecth*3600*12
// }
//decompose t into the 3 arms
//vh = (t/3600);
//vm = ((t%(3600))/60);
//vs = ((t%(3600))%60);
// make arms move
//sx = Rs*Math.sin(vs/60*pi2);
//sy = Rs*Math.cos(vs/60*pi2);
//mx=Rm*Math.sin(vm/60*pi2);
//my=Rm*Math.cos(vm/60*pi2);
//hx=Rh*Math.sin(vh/12*pi2);
//hy=Rh*Math.cos(vh/12*pi2);
//store value for drag to work
vhs = vh;

No comments:
Post a Comment