NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => Questions related to EJS => Topic started by: lookang on September 22, 2008, 12:14:45 pm



Title: how to make a slider time t that allows user to slide to replay simulation
Post by: lookang on September 22, 2008, 12:14:45 pm
how to make a slider time t that allows user to slide to replay simulation

is there any easy way to implement a slider bar t that will allow scrolling back in time like a movie player control for any simulation?

i notice in http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=188.msg2817#new

in slider property
variable = ts
enabled = _isPaused
on drag = dragt()

under model custom
public void dragt () {
 PY1[2]=v1s=v10+a1*ts;
 PY2[2]=v2s=v20+a2*ts;
 x1s=x10+v10*ts+a1*ts*ts/2;
 x2s=x20+v20*ts+a2*ts*ts/2;
 PT[2]=PT[3]=ts;
}

this appears to be a way you designed to control the playback controller due to known equations of motion under constant acceleration.

Is there a easy way to do a playback controller for time t for any simulation that it just played ?
i was hoping maybe some library java may have it ;D

thanks!



Title: Re: how to make a slider time t that allows user to slide to replay simulation
Post by: Fu-Kwun Hwang on September 22, 2008, 02:12:08 pm
I used the equation because this is a simple case and I know the equation.
For all general type of simulations, what you need to do is make dt become negative value and you can reverse the time.
You can add code to ask the program to stop at any point you want.
So you can change direction of time when you program the simulation - You are the GOD of your simulation - you can do whatever you want with your simulation : You just need to figure a way to do it! (It is how we use our mind to make it work -- this is more important than always depend on library from others.)


Title: Re: how to make a slider time t that allows user to slide to replay simulation
Post by: lookang on September 22, 2008, 02:36:43 pm
For all general type of simulations, what you need to do is make dt become negative value and you can reverse the time.
You can add code to ask the program to stop at any point you want.
So you can change direction of time when you program the simulation - You are the GOD of your simulation - you can do whatever you want with your simulation : You just need to figure a way to do it! (It is how we use our mind to make it work -- this is more important than always depend on library from others.)


wow! that is a good idea for making the simulation run back in time.

but the logic is the same for silder bar ?.....hmmmmm i need to think.