One dimensional motion with constant velocity.
Code
Changes are highlighted in red.
<html>
<head>
<title>Animator NCSU Example</title>
<script language="JavaScript">
var ball_1 = 0;
var ball_2 = 0;
function initialize(){
document.myAnimator.setShapeRGB(255,0,0);
ball_1 = document.myAnimator.addObject("circle", "x=-22+(12*t),y=-2,r=10");
eq = "-20";
document.myAnimator.setShapeRGB(0,0,255);
ball_2 = document.myAnimator.addObject("circle", "x="+eq+", y=2,r=10");
document.myAnimator.setTimeOneShot(5,"End");
document.myAnimator.setTrail(ball_1,300);
document.myAnimator.setFootPrints(ball_1,20);
document.myAnimator.setGhost(ball_1,true);
document.myAnimator.setTrail(ball_2,300);
document.myAnimator.setFootPrints(ball_2,20);
document.myAnimator.setGhost(ball_2,true);
document.myAnimator.setAutoRefresh(true);
document.myAnimator.forward();
}
function prob1()
{ document.myAnimator.reset();
eq = document.myform.equation.value;
document.myAnimator.setTrajectory(ball_2, eq, "2");
document.myAnimator.forward();
}
</script>
</head>
<body onload="JavaScript:initialize()">
<h2>One dimensional motion with constant velocity.</h2>
<form name=myform>
<center>
<br>
<applet code="animator4.Animator.class"
codebase="../classes" id="myAnimator" name="myAnimator"
archive="Animator4_.jar,DataGraph4_.jar,STools4.jar"
width="500" height="200">
<param name="FPS" value="10">
<param name="dt" value="0.02">
<param name="pixPerUnit" value="10">
<param name="gridUnit" value="1.0">
<param name="showControls" value="false">
</applet>
<br>
<input type=button value="Run" onClick="Javascript:document.myAnimator.forward()">
<input type=button value ="Step Forward" onClick="Javascript:document.myAnimator.stepTimeForward()">
<input type=button value ="Step Backward" onClick="Javascript:document.myAnimator.stepTimeBack()">
<input type=button value="Pause" onclick=Javascript:document.myAnimator.pause()>
<input type=button value="Reset" onclick="Javascript:document.myAnimator.reset()">
</center>
Write the equation of motion for the red ball in the box below. Your equation will look
something like:
<blockquote><i>x</i> + <i>v</i>*t <br>
<input type=text name=equation value="0 + 0*t ">
<input type=button value="Run with new equation" onClick="JavaScript:prob1()">
</blockquote>
<p></form>
<h3>Code</h3>
</body>
</html>