Hi Prof,

i like the simulation above and wish to add an option for the simulation [color=blue]to start on a straight horizontal track.[/color]

i encounter a problem in introducing a new stage i called [color=blue]stage==4  [/color]

IN FIXED RELATIONSHIP i added
[color=blue][b]else if(stage==4){ // moving in straight motion on the start track by lookang
stagetext = "moving in straight line motion on the start track";
omega=0;
v=vx;
cst = 0; // turn off gravity
// x=xmin + vx*t;
//y=ymin+size2;
cf=0;
nf=m*(g); // change by lookang
cta=3*pi/2; //  -pi/2 ;possible bug identified by lookang as angle is not consistent as vertical to velocity vector counterclockwise +
acentre = 0;
atangent = 0;
aresultant = Math.sqrt(acentre*acentre+atangent*atangent);
}[/b][/color]

but i cannot figure out by myself the meaning of EVENT
[b][color=red]what should i do to allow an option to start on a horizontal track[/color][/b], similar to the stage 2 exit horizontal track? :)

i tried to edit the EVENT Zero condition
//if(stage==4)return -cta-pi/2;
if(stage==0[color=red][b]||stage==4)[/b][/color]return -cta-pi/2; // but this does not work
//  else if(stage==4)return -cta-pi/2;
else if(stage==1){
 if(cta>0 && cta<pi){
   return r2*omega*omega-g*Math.sin(cta);
 }
 return 1.5*pi-cta;
}
return 1.0;

the ACTION is also edited to reflect the resulting omega if it moves from stage 4 ( i introduced) to stage 1 ( circular track)
if(stage==0){
 stage=1;
 omega=omega*R2/r2;
}
[color=blue][b]if (stage==4){
   stage=1;
 omega=vx/r2;
 }[/b][/color]

else if(stage==1){
if(cta>0 && cta<pi){//free fall
 stage=3;
 v=r2*omega;
 x=xmin+R+r2*Math.cos(cta);
 y=ymin+r+r2*Math.sin(cta);
 vx=-v*Math.sin(cta);
 vy=v*Math.cos(cta);
 cst=-1;
}else if(cta>4.5){//complete loop
 stage=2;
 vx=r2*omega;
 vy=0;
 y=ymin+size2;
 x=xmin+R;
}
}

attached is my ejs for your understanding what i am trying to do.
i also attached the ejs simulation for quick testing
the picture shows the error i suspect it due to my lack of understanding the meaning of Events and the syntax of "return" and how to use it.  
to change stage, the right bottom has a field for manual input to '4' from '0' to activate the stage 4 //start on a straight horizontal track.

any chance you can modify your simulation so that i can observe the new source codes?
or some tips for me to work on :)

thanks!


/htdocs/ntnujava/ejsuser/14019/users/sgeducation/lookang/coaster4weeoption_pkg/coaster4weeoption.propertiesFull 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
Download EJS jar file(998.7kB):double click downloaded file to run it. (5 times by 4 users) , Download EJS source View EJS source