# NTNUJAVA Virtual Physics LaboratoryEnjoy 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 November 28, 2008, 09:19:14 am

 Title: how to view the valuesofvariables declared inside for ODE Evolution Page in EJS? Post by: lookang on November 28, 2008, 09:19:14 am how to view the values of variables declared inside for ODE Evolution Page in EJS?For example,Code:double deltax = x-x, deltay = y-y; // double deltaVx = vx-vx, deltaVy = vy-vy;double distance = Math.sqrt(deltax*deltax+deltay*deltay)-diameter/2*2;  //      if (deltax*deltaVx+deltay*deltaVy<0) { return distance; }return TOLERANCE;Action:Code:double vcmx = (vx+vx)/2;  // vcm is center of mass velocity in laboratorydouble vcmy = (vy+vy)/2;double deltax = x-x, deltay = y-y;double r=Math.sqrt(deltax*deltax+deltay*deltay);  // separationdeltax = deltax/r;  // normalized separation x componentdeltay = deltay/r;  // normalized separation y component// transform into CM systemvx=vx-vcmx;vy=vy-vcmy;vx=vx-vcmx;vy=vy-vcmy;// compute collisionsdouble dot=deltax*vx+deltay*vy; // particle 0 projection along line of centersvx=vx-2*dot*deltax;vy=vy-2*dot*deltay;dot=deltax*vx+deltay*vy;        // particle 1 projection along line of centersvx=vx-2*dot*deltax;vy=vy-2*dot*deltay;// transform into laboratoryvx=vx+vcmx;vy=vy+vcmy;vx=vx+vcmx;vy=vy+vcmy;I normally recreate the variables in event in the main variable tab/page and copy and paste the relationship/equation in "fixed relations tab" to track the values as the simulation run.Example of Fields: that i want to see what they are calculatingdeltax = 0.00deltay = 0.00deltaVx = 0.00deltaVy = 0.00distance = 0.00is there an easier way to do track variables declared inside the event and for the matter custom functions ?  ;D Thanks! Title: Re: how to view the valuesofvariables declared inside for ODE Evolution Page in EJS? Post by: Fu-Kwun Hwang on November 28, 2008, 11:03:57 am In the custom page, you declear variable as local scope:double deltax = x-x, deltay = y-y; // double deltaVx = vx-vx, deltaVy = vy-vy;double distance = Math.sqrt(deltax*deltax+deltay*deltay)-diameter/2*2;  //    So deltax,deltaVx and distance are only available in the custom page. If you want to use those variable (or any variable globally). Define variable in the Variable tabs.And you can access all variables defined in the Variable tabs anywhere in the ejs program.So you need to define deltax,deltaVx and distance , and change the above code todeltax = x-x, deltay = y-y; // deltaVx = vx-vx, deltaVy = vy-vy;distance = Math.sqrt(deltax*deltax+deltay*deltay)-diameter/2*2;  //    And you can assign the above variables to any view element to find out their value!