NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
October 24, 2017, 10:56:54 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
You cannot always have happiness but you can always give happiness. ..."Mother Teresa(1910-1997, Roman Catholic Missionary, 1979 Nobel Peace Prize)"
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: how do make Ejs applet run forever unless the pause or reset  (Read 4863 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
on: June 21, 2010, 01:45:23 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

how do make Ejs applet run forever (time increase by dt ) unless the pause or reset?

i have a strange applet which i remixed from, i tried to track down the codes for the end of simulation but i don't see any.

any idea what is causing the applet to end?

you can make the applet end by changing e=0, i thought it would continue to count t which is what i wanted.

Embed a running copy of this simulation

Embed a running copy link(show simulation in a popuped window)
Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
Press the Alt key and the left mouse button to drag the applet off the browser and onto the desktop. This work is licensed under a Creative Commons Attribution 2.5 Taiwan License
  • Please feel free to post your ideas about how to use the simulation for better teaching and learning.
  • Post questions to be asked to help students to think, to explore.
  • Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #1 on: June 21, 2010, 03:23:53 pm » posted from:Taipei,T\'ai-pei,Taiwan

I did check out your ejs code.
There are several strange code
1. Why the drawingPanel was assigned to be autoscale?
2. Why maxX= -carSize/2 Huh
3. Why Lmax was not defined?
...

You should have assigned initlal value for defined variables.
I do not know how to change your code because I do not know the specification for your simulation.

The code in the event are strange,too!

If I have something bounced between xmin and xmax (xmax>xmin)

I will have code like this for zero condition:
Code:
if (v>0)return x-xmax; // bounced at x=xmax
else if(v<0)return x-xmin; // bounced at x=xmin
return 1;
// the event occurs when return value is less than zero.

And the action will be
Code:
v=-e*v;

Embed a running copy of this simulation

Embed a running copy link(show simulation in a popuped window)
Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
Press the Alt key and the left mouse button to drag the applet off the browser and onto the desktop. This work is licensed under a Creative Commons Attribution 2.5 Taiwan License
  • Please feel free to post your ideas about how to use the simulation for better teaching and learning.
  • Post questions to be asked to help students to think, to explore.
  • Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #2 on: June 21, 2010, 04:59:54 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

I did check out your ejs code.
There are several strange code
1. Why the drawingPanel was assigned to be autoscale?
so that maximum view is achieved.
Lmax was original 10, i need to customize it to only 1 metre cos in school, the length of the ramp is about 1.2 m
if i keep Lmax = 10 m, and i vary L, the mainview becomes a very small car and ramp with about of empty space, because L = 10m, so i made L = 1m
and with autoscale, the view is squared and maximum. should i make the view constant?


2. Why maxX= -carSize/2 Huh
it is commented cos i was debugging it. Cheesy
Fixed relations.FixRel Page(43): //maxX= -carSize/2;

3. Why Lmax was not defined?
Lmax = 0.

You should have assigned initlal value for defined variables.
ok, but i blank them because the applet accepts new values after reset button, which is how i make the applet remember/stored previous user inputs without much troublesome variables assignment techniques such as variable_stored to remember last user values.

I do not know how to change your code because I do not know the specification for your simulation.

The code in the event are strange,too!

If I have something bounced between xmin and xmax (xmax>xmin)

I will have code like this for zero condition:
Code:
if (v>0)return x-xmax; // bounced at x=xmax
else if(v<0)return x-xmin; // bounced at x=xmin
return 1;
// the event occurs when return value is less than zero.

And the action will be
Code:
v=-e*v;

interesting, i never did zero crossing before! thx for the tip!

i modify the idea from Ejs default examples http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=797.0
but you are right, i could not get the applet to detect the state correctly sometimes, so i changes the dt =0.1 to 0.05 s thinking it will lesser the detection state error.
i have adopted your zero crossing method
Code:
if (v>0) return x+carSize/2-xbumperbottom; // bounced at x=xmax
else if(v<0)return x-carSize/2-xbumpertop; // bounced at x=xmin or x+carSize/2
return 1.0;
//return 1.0;
action
Code:
v=-e*v;
will try all the more elegant coding!
thx!
« Last Edit: June 21, 2010, 05:05:30 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #3 on: June 21, 2010, 07:52:30 pm » posted from:Taipei,T\'ai-pei,Taiwan

Quote
ok, but i blank them because the applet accepts new values after reset button, which is how i make the applet remember/stored previous user inputs without much troublesome variables assignment techniques such as variable_stored to remember last user values.

The effect you need is better done with _initialize() instead of _reset()

Write code need to be initialized at initlalize page and EJS will remember user's inputs.

_reset() is used to restart everything.
Logged
Pages: [1]   Go Up
  Print  
You cannot always have happiness but you can always give happiness. ..."Mother Teresa(1910-1997, Roman Catholic Missionary, 1979 Nobel Peace Prize)"
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
how to make the text b always appear after the simulation is reset?
Dynamics
lookang 16 15339 Last post July 26, 2007, 11:40:25 pm
by Fu-Kwun Hwang
is it possible to make applet make a sound when i condition is met?
Questions related to EJS
lookang 8 10203 Last post December 22, 2008, 12:10:01 pm
by lookang
how to make a slider remember previous value after reset simulation.
Questions related to EJS
lookang 2 6002 Last post January 20, 2009, 01:37:25 pm
by lookang
How to make an applet that is controlled by F (length) and angle (cta)
Questions related to EJS
lookang 4 7902 Last post March 02, 2009, 10:22:45 pm
by Fu-Kwun Hwang
how to make magnet1 and magnet2 in a single applet with different rotation?
Questions related to EJS
lookang 1 4095 Last post May 01, 2010, 01:50:08 pm
by lookang
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.059 seconds with 23 queries.since 2011/06/15