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 February 11, 2009, 09:28:22 am



Title: How to make the trace in a plot to clear after _initialize()
Post by: lookang on February 11, 2009, 09:28:22 am
I am making changes to the initialization page
// to make the button initialise do the same thing as reset thanks to tips
t = 0;
// bring carts to start position
x1 = -0.8 ;
x2 = 0 ;
 

but i realize the plot trace draw a line back to (t,momentum) = (0,0)

when do i add the line make the trace clear ?


And suddenly, i remember Christain Wolfgang codes.
i just understood how to do this by using on initialisation page.

_view.trace.clear();



cool, i solve it myself ?!
when typing then i realised, so just post it for others to read. ;)


Title: Re: How to make the trace in a plot to clear after _initialize()
Post by: Fu-Kwun Hwang on February 11, 2009, 11:19:31 am
You can check out Fire work (projectile motion) (http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=944.0) and find out how I did it.


Title: Re: How to make the trace in a plot to clear after _initialize()
Post by: lookang on February 16, 2009, 01:11:07 pm
interesting way and good.

i see
declare variable "clear" type boolean in variable page

insert clear into into traceset clear at input as in picture.

insert codes in fixed conditions

if(t<dt)clear=true;       // appears to clear if t smaller than dt, so that is in the beginning?
else clear=false;
if(count>=n || (t>tf && t>ts+td)){ // another condition to clear true :)
   clear=true;           
   _initialize();
 }

Thanks!
am i roughly correct?


Title: Re: How to make the trace in a plot to clear after _initialize()
Post by: Fu-Kwun Hwang on February 16, 2009, 05:16:07 pm
Yes. I think you got the ideas.
There are more than one way to do it. You can try other options, too! ;)