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

## Easy Java Simulations (2001- ) => Collaborative Community of EJS => Topic started by: lookang on November 27, 2008, 02:05:21 pm

 Title: Free Fall Cartesian by Wolfgang Christian and Francisco Esquembre Post by: lookang on November 27, 2008, 02:05:21 pm Free Fall Cartesian extends the Free Fall model of a ball bouncing on a table top to include motion in the x (horizontal) direction.   Title: Re: Free Fall Cartesian by Wolfgang Christian and Francisco Esquembre Post by: minstor on January 30, 2009, 10:28:48 pm Very interesting post!M.Minstor,-*- Title: Re: Free Fall Cartesian by Wolfgang Christian and Francisco Esquembre Post by: lookang on August 03, 2009, 11:21:23 am The model includes a trace that shows the ball's trajectory as well as a more sophisticated collision algorithm that takes into account the finite width of the table top.  Newton's second law F = ma  is a vector equation and  it must be satisfied in both the horizontal and vertical direction.Fx = max Fy = may .Because the force in the x (horizontal) direction is zero, the associated acceleration ax is also zero and the velocity vx is constant.  As in the Free Fall model, an impulsive normal force acting perpendicular to the table top reverses the ball's velocity upon collision.  The table top corner is treated as a special case.  The impulsive force from a corner collision is applied along a line from the corner toward the ball center.References:The Free Fall in Cartesian Coordinates model is designed to teach Ejs modeling.  Right click within the simulation to examine this model in the Ejs modeling and authoring tool.  See:"Modeling Physics with Easy Java Simulations" by Wolfgang Christian and Francisco Esquembre, The Physics Teacher, November 2007, 45 (8), pp. 475-480.The Easy Java Simulations (EJS) documentation can be downloaded from the ComPADRE Open Source Physics collection and from the Ejs website.Note:This simulation was created by Wolfgang Christian using the Easy Java Simulations (Ejs) modeling tool. You can examine and modify this simulation if you have Ejs installed by right-clicking within a plot and selecting "Open Ejs Model" from the pop-up menu. Information about Ejs is available at: .Because the Free Fall 2D model uses 9 variables we have chosen to create two variable tables in Ejs.  The table of dynamic variables contains values that evolve in time while the table of constant parameters contains values that remain fixed.  Creating separate tables to group variables is an effective way to organize data in Ejs models.Horizontal motion adds a third differential equation to the Ejs evolution page.  We do not include a differential equation for vx because there is no force in the x direction.Modeling the bounce on a finite table requires that we modify the previous Ejs collision event so that it occurs only when the the ball's x-position is between the table top corners.  As in the Free Fall event, a collision occurs only if the ball is moving downward.Ejs supports multiple events and we have added a corner collision event (Event 2 is not shown here) to the model.  If the time evolution produces one or more event triggers, Ejs automatically attempts a smaller time step until it finds a time when the zero condition is satisfied for all events.  It is therefore very important that Ejs models be initialized in such a way that all events return positive values when testing the zero condition.  Otherwise, Ejs cannot find a valid starting time and the time evolution algorithm will fail.Tip: You can temporarily disable an event by right clicking on the tab near the top of the events page.  Right-clicking within the coding text areas provides context-sensitive help.My contributions are1. comment lines on the events codes.Event1:Code:if(vy>=0) return 1;                    // ball is moving up so collision has occuredif(Math.abs(x)>floor_size/2) return 1; // ball center is past right table edge, do nothing// starting ball x = -0.5 centre x =0, right x =0.5, so programming is floor_size/2 since floor_size=1.0 declaredreturn y-ball_radius;                  // displacement of ball center above floor, return back to y-ball_radiusAction1:Code:// action if particle is falling and below the floorvy = Math.abs(vy)*coef_of_restitution;Event2:Code:if(vy>=0) return 1;                 // ball is moving up so collision has occureddouble dx=Math.abs(x)-floor_size/2; // distance of ball past cornerif(dx<=0) return 1;                 // ball is on tableif(dx-ball_radius>=0) return 1;     // ball is past cornerdouble r=ball_radius;return y-Math.sqrt(r*r-dx*dx);      // displacement of ball center above edgeAction2:Code:// action if particle is hitting corner of tabledouble cos=y/ball_radius;double sin=(x<0)?(x+floor_size/2)/ball_radius:(x-floor_size/2)/ball_radius;//double sin -> declares a variable of the numerical data type "double", allowing it to have decimal spaces// if the x is lesser than 0//it will evalulate the formula behind it and set the value of "sin" to its result// it helps to visualise the angle made inside the circle one side is r the other is y.between //rotate system //to along surface of collison and perpendicular to surface of collisiondouble vx2= cos*vx-sin*vy; // vx2 is the velocity along the surface of collisiondouble vy2= sin*vx+cos*vy; // vy2 is the velocity pendicular the surface of collision// do corner collisionvy2 = Math.abs(vy2)*coef_of_restitution;//rotate back// to the x and y coordinate systemvx= cos*vx2+sin*vy2; // actually it is cos vx2 + cos(90-teta)vy2vy=-sin*vx2+cos*vy2; //actually it is -sin vx2 + sin(90-teta)vy22. panel for inputs of variables like vx and vy so that students can explore when if scenariossource codedownload the *.jar for using the applet on standalone without internet connection.This is starting to get difficult for me ;D