Enjoy the fun of physics with simulations!

Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Title: Position vs. TimePost by: lookang on March 10, 2009, 12:45:47 pm
Position vs. Time
This experiment uses the computer and the multimedia system to display graphs of Distance vs Time, Velocity vs Time and Acceleration vs Time. (http://www.phys.ufl.edu/demo/1_Mechanics/D_MotionTwoDimensions/PersonMotionsensor.jpg) http://www.phys.ufl.edu/demo/1_Mechanics/D_MotionTwoDimensions/PersonMotionsensor.html i can figure out the rest except the click to drag part with a running time. may be i need some example to follow the syntax ;D Title: Re: Position vs. TimePost by: lookang on March 10, 2009, 04:41:20 pm
strange, i cant modify my post after some time? is that a new feature?
anyway i was planning to quickly demonstrate how quickly i can get this to work but...... question: 1. the evolution page is dx/dt = v i got the time t to increment by dt = 0.05, but the v does not vary as i change the position of circle coordinate (x,y) 2. on drag of (x,y) i notice the time t is slower than when no drag of the (x,y), how to make the increment of time constantly, independent of the interaction/calculation of the applet, to simulate like real time for example? thansk!, attached is my attempt to make this applet in 10 minutes .:) Title: Re: Position vs. TimePost by: Fu-Kwun Hwang on March 10, 2009, 05:35:42 pm
The equations dx/dt=v at evolution page, tell EJS use the current value v to calculate x (t+dt) from x(t).
It does not have any other effect. The left hand side will change according to value at the right hand side of the equation. It is not the reversed order. In computer language: x=x+1; does not mean "x equal to x+1" which is always false. It mean get value from x, add 1 and save the value back to x. I do not understand what do you mean by Quote i got the time t to increment by dt = 0.05, but the v does not vary as i change the position of circle coordinate (x,y) What is your expectation? I do not understand what you really want to do. Please explain it in more detail. The EJS simulation use the equation at evolution pages to calculate new value at t+dt from value at t. And it does not remember previous values unless you add an array to store those values. If you want to use mouse action to change the time , you need to save values for all the variables or add code to move the time either forward or backward. Title: Re: Position vs. TimePost by: lookang on March 10, 2009, 08:25:35 pm
strange mesage.
cannot download source or jar You need to login to ntnujava forum in order to download files. the applet: i wanted to be able to drag the circle (x,y) along the x direction only, just like the real life case of a man moving forward and back to observe the graph of s vs t, v vs t, a vs t. so the rate of me dragging the circle, determines the graphs. drag slowly constant speed, gives s = v*t graph and v = v graph and a = 0 graph i can't find any example on the public internet. private one i see before but i cannot link to them. let me continue to search! wait i think i am having a eureka moment. i think i figure out already i tried evolution page only: x1 = x; t = t + dt; x2 = x; v = (x2 - x1)/dt; custom function: drag() // this is to make on drag(), t to increase still. to create illusion of time still running because without this, the drag moment t is not changing. x1 = x; t = t + dt; x2 = x; v = (x2 - x1)/dt; but i seems to get no value for v. i can't seems to create the difference in the value of x to be assigned to x2 and x1 differently despite the the line of code t = t+ dt; Title: Re: Position vs. TimePost by: Fu-Kwun Hwang on March 10, 2009, 11:06:44 pm
It is a bug. I was wondering why no one download user uploaded jar files in the last week.
I just modified the code. You should be able to download it now. I though you have did similar work before. May be you can check out Integrator y= ∫ f(x) dx (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=806) You can drag the blue dot, which is follow the curve of of the function (user can input different function). And the red curve is the integal of the function. Title: Re: Position vs. TimePost by: lookang on March 11, 2009, 07:53:50 am
it looks like i have done similar work but to create knowledge on my own is really difficult, and i can't seem to find the parts where you explained how to get velocity from first principles. so i am making up the knowledge (codes) from my thoughts and experience.
I still have a lot to learn :) i just saw the xml. thanks! my current xml also can drag. i just found a applet that is similar to what i was thinking of. http://www.mste.uiuc.edu/users/Murphy/MovingMan/MovingMan.html i see Lisa Denise Murphy at the University of Illinois has one made in 1997 let me study it Title: Re: Position vs. TimePost by: Fu-Kwun Hwang on March 11, 2009, 09:26:11 am
If you just want to show trace similar to the applet at http://www.mste.uiuc.edu/users/Murphy/MovingMan/MovingMan.html
Just add n trace in EJS, and enter x,y property as t and x position. Let the applet change to play mode when user starts to drag the object and enter pause mode when user release the mouse. Then you will get what you want! Check out the following applet (drag the blue dot). Title: Re: Position vs. TimePost by: lookang on March 11, 2009, 01:19:13 pm
nice!.
mine is ok too. i just can't seem to get the first principle of velocity v = (x2 -x1)/dt to work. Title: Re: Position vs. TimePost by: Fu-Kwun Hwang on March 11, 2009, 03:28:23 pm
Please write down the code you sued to calculate velocity v.
You applet did not support v=0. But my previous applet does. Title: Re: Position vs. TimePost by: lookang on March 11, 2009, 04:38:28 pm
x1 = x;
t = t + dt; // i can't seems to create the difference in the value of x to be assigned to x2 and x1 differently despite the the line of code t = t+ dt; x2 = x; v = (x2 - x1)/dt; but i seems to get no value for v. it shouldn't be that difficult, but i can't figure out. can save me? ;D Title: Re: Position vs. TimePost by: Fu-Kwun Hwang on March 11, 2009, 05:53:47 pm
x1=x; // value of x copy to x1
t=t+dt; // value of t add dt and copy result to t x2=x;// the same x value copy to x2, so x2 is the same as x1 So v=(x2-x1)/dt is always equal to 0. If you want to calculate velocity, you need to save previous x, support we save it as xs (define xs first). Add the following line in the Fixed relations Page:v=(x-xs)/dt; // x is the new value , and xs is the previous one. xs=x;// save x value to xs You should not reverse the above order. otherwise, you will get the same result=0. You can add x=xs= (your initial value) at the Initialization page.Title: Re: Position vs. TimePost by: lookang on March 11, 2009, 07:47:34 pm
excellent tip!
i must remember how to do this again. it works now. thanks a million! ;D |