[inline]
[script type=”text/javascript”]
var width=500;
var height=500;
var xrange=10;
var yrange=10;
mx = width/(2.0*xrange);
bx = width/2.0;
my = -height/(2.0*yrange);
by = height/2.0;
function draw8587(ctx, polys) {
t=t+dt;
//ctx.fillText (“t=”+t, xp(5), yp(5));
ctx.clearRect(0,0,width,height);
polys[0].drawAxes(ctx);
//drawAxes(ctx);
ctx.lineWidth=3;
//ctx.beginPath();
//ctx.moveTo(x1,y1);
//ctx.lineTo(x2,y2);
//ctx.stroke();
//ctx.closePath();
//y2+=dyp(dy);
// add polynomial timing
// First move (from y=0 to y=1)
if (polys[0].c < 1.0) {
polys[0].c = polys[0].c + 2.0*dt*change*move_dir;
}
// Second move (change from y=1 to y=0.5x+1)
else if (polys[0].b < 0.5) {
polys[0].b = polys[0].b + dt*change*move_dir;
polys[0].order = 1;
}
// Third move (change from y=0.5x+1 to y=0.5x+4)
else if (polys[0].c < 4.0) {
polys[0].c = polys[0].c + 2.*dt*change*move_dir;
//polys[0].order = 1;
}
else {
//move_dir = move_dir * -1;
end_ct = end_ct + dt;
if (end_ct >= dt*40) {
polys[0].a = 0;
polys[0].b = 0;
polys[0].c = 0;
polys[0].order = 0;
}
}
ctx.textAlign=”center”;
ctx.textBaseline=”alphabetic”;
ctx.font = “14pt Arial”;
ctx.fillStyle = ‘#f00’;
ctx.fillText (“Equation of a Line”, xp(-5), yp(9));
ctx.fillText (“y = mx + b”, xp(-5), yp(5));
ctx.font = “12pt Arial”;
//ctx.fillText (“y = “+polys[0].b.toPrecision(1)+”x + “+ polys[0].c.toPrecision(2), xp(-5), yp(7));
ctx.fillText (“b = intercept = “+polys[0].c.toPrecision(2), xp(-7), yp(3));
//draw polynomials Here’s a prototype for showing how the equation of a straight line changes as you change its slope (m) and intercept (b): It starts with an horizontal line along the x-axis, where the slope is zero and the intercept is zero: The line moves upward, but stays horizontal, until the intercept is 1.0: The slope increases from horizontal (m = 0), gradually, until the slope is 0.5: Finally, we move the line upwards again, without changing the slope (m = 0.5), until the intercept is equal to 4.0: Now I just need to figure out how to make them interactive.
ctx.lineWidth=3;
for (var i=0; i