Remix Legally by lookang
1. added another function input and graphics
2. change color scheme function 1 = blue, function 2 = black, sum = RED
3. added drop down menu for scaffolds and ease of exploration
4. added pedagogical options equations in como dropdown menu "sin(x-t);0.5*sin(x-t);2*sin(x-t);sin(0.5*x-t);sin(2*x-t);sin(x-0.5*t);sin(x-2*t);sin(x-t-0.785);sin(x-t-1.57)" and "sin(x+t);0.5*sin(x+t);2*sin(x+t);sin(0.5*x+t);sin(2*x+t);sin(x+0.5*t);sin(x+2*t);sin(x+t+0.785);sin(x+t+1.57)"
5. slider bar for n number of points to plot inbetween the screen
6. redesign interface to be bottom panel HORIZONTAL
7. added debug panel on the left set visible FALSE
The Wave Function Plotter model was created by Wolfgang Christian and Francisco Esquembre using the Easy Java Simulations (EJS) version 4.1 authoring and modeling tool. You can examine and modify a compiled EJS model if you run the model (double click on the model's jar file), right-click within a plot, and select "Open Ejs Model" from the pop-up menu. You must, of course, have EJS installed on your computer. Information about Ejs is available at: and in the OSP ComPADRE collection .
Wave Function Plotter
A wave is a disturbance, such as sound, that propagates through space. For a wave propagating in one dimension, we use a wave function u(x,t) to represent the wave at position x and time t as shown in the screen shot. Although a sinusoidal wave function is a very common type type of disturbance, we should remember that there are many other wave functions, such as shock waves, that do not fit this functional form.
The model's fixed relations workpanel computes the data by evaluating the parser in the EJS Function element the using the following code:
double dx = (xmax-xmin)/n; // sample interval double x=xmin+dx/2; // position _view.trail.clear(); // clear old data for(int i=0; i
codes modified are
double dx = (xmax-xmin)/n; // sample interval
double x=xmin+dx/2; // position
_view.trail.clear(); // clear old data
_view.trail1.clear(); // need this else it will become a mess of points and make sure trail trail1 trail2 are names of the trail 2D element.
_view.trail2.clear(); // need this else it will become a mess of points
for(int i=0; i double u = _view.waveFunction.evaluate(x,t); // evaluate wave function // make sure waveFunction is name of input function interface
_view.trail.addPoint(x,u) ; // add data to trace // make sure name trail is name of trail 2D to _view.trail.addPoint(x,u)
//type _view. for scaffolds super cool!
// added by wee for another functionplot1
double u1 = _view.waveFunction1.evaluate(x,t); // evaluate wave function
_view.trail1.addPoint(x,u1); // add data to trace
// added by wee for sum
//sum = u+ u1 ;
sum = _view.waveFunction.evaluate(x,t)+_view.waveFunction1.evaluate(x,t);
// summax = %sum_string%;
x += dx; // increment position
old code used for http://home.phy.ntnu.edu.tw/~lookang/