sims.experimental.GraphCalcApp

vorherig nächste

This demonstrates using the myPhysicsLab library to draw graphs with JavaScript in the Terminal command line.

This graph shows a single GraphLine. However, you can change the style (color, line width, dots vs. lines) at any time, so it can look like there are several different graphs being drawn.

To clear all points from the GraphLine:

  graphLine.reset();

To plot a new graph use the "plot" command. This adds points to the GraphLine, with the value for "x" going between the two given numbers.

  plot("x*x", -5, 5);

You can specify the number of points plotted as the 4th argument to plot (the default is 200). To add points to the GraphLine in a new color:

  graphLine.setColor("red");
  plot("-x*x", -5, 5, 50);

To change the area being shown (arguments are left, bottom, top, right)

  simView.setSimRect(new DoubleRect(-6, -30, 6, 30));

To change line width or drawing mode:

  graphLine.setLineWidth(2);
  plot("x", -10, 10);
  graphLine.setDrawingMode("dots");
  graphLine.setColor("black");
  plot("-x", -10, 10);

To redraw the entire GraphLine with a different style:

  graphLine.setColor('blue');
  graphLine.resetStyle();
  graph.reset();

To create a URL with a script that draws an equation: you can provide any of the above commands in the "query" portion of the URL (after the question mark) for this web page. Example:


https://www.myphysicslab.com/develop/build/sims/experimental/GraphCalcApp-en.html?graphLine.reset()

;plot("8*Math.sin(x/2)*Math.sin(10*x)",-10,10,1000);



Valid HTML 4.01