Difference between revisions of "Polar curve plotter"

From JSXGraph Wiki
Jump to navigationJump to search
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
<html>
 
<html>
 
<p>
 
<p>
   <textarea cols=60 rows=4 id="eingabe">function r(t) {return t; };
+
   <textarea cols=60 rows=4 id="eingabe">function r(t) {return 0.2*t; };
 
</textarea><br />
 
</textarea><br />
 
   <input type="button" value="plot" onClick="plot()">
 
   <input type="button" value="plot" onClick="plot()">
Line 10: Line 10:
 
board = JXG.JSXGraph.initBoard('jxgbox', {axis:true, boundingbox:[-5,5,5,-5]});
 
board = JXG.JSXGraph.initBoard('jxgbox', {axis:true, boundingbox:[-5,5,5,-5]});
 
a = board.createElement('slider', [[0,-1],[3,-1],[-4*Math.PI,0,0]], {style:6, name:'a'});
 
a = board.createElement('slider', [[0,-1],[3,-1],[-4*Math.PI,0,0]], {style:6, name:'a'});
b = board.createElement('slider', [[0,-2],[3,-2],[0,1,4*Math.PI]], {style:6, name:'b'});
+
b = board.createElement('slider', [[0,-2],[3,-2],[0,7,4*Math.PI]], {style:6, name:'b'});
 
function plot(){
 
function plot(){
 
   eval(document.getElementById("eingabe").value);
 
   eval(document.getElementById("eingabe").value);
Line 25: Line 25:
 
function clearAll() {  
 
function clearAll() {  
 
   JXG.JSXGraph.freeBoard(board);
 
   JXG.JSXGraph.freeBoard(board);
   board = JXG.JSXGraph.initBoard('jxgbox', {axis:true, originX: 250, originY: 250, unitX: 50, unitY: 50});
+
   board = JXG.JSXGraph.initBoard('jxgbox', {axis:true, boundingbox: [-5, 5, 5, -5]});
 
   a = board.createElement('slider', [[0,-1],[3,-1],[-4*Math.PI,0,0]], {style:6, name:'a'});
 
   a = board.createElement('slider', [[0,-1],[3,-1],[-4*Math.PI,0,0]], {style:6, name:'a'});
   b = board.createElement('slider', [[0,-2],[3,-2],[0,1,4*Math.PI]], {style:6, name:'b'});
+
   b = board.createElement('slider', [[0,-2],[3,-2],[0,7,4*Math.PI]], {style:6, name:'b'});
 
}
 
}
  
Line 37: Line 37:
 
board = JXG.JSXGraph.initBoard('jxgbox', {axis:true, boundingbox:[-5,5,5,-5]});
 
board = JXG.JSXGraph.initBoard('jxgbox', {axis:true, boundingbox:[-5,5,5,-5]});
 
a = board.createElement('slider', [[0,-1],[3,-1],[-4*Math.PI,0,0]], {style:6, name:'a'});
 
a = board.createElement('slider', [[0,-1],[3,-1],[-4*Math.PI,0,0]], {style:6, name:'a'});
b = board.createElement('slider', [[0,-2],[3,-2],[0,1,4*Math.PI]], {style:6, name:'b'});
+
b = board.createElement('slider', [[0,-2],[3,-2],[0,7,4*Math.PI]], {style:6, name:'b'});
 
function plot(){
 
function plot(){
 
   eval(document.getElementById("eingabe").value);
 
   eval(document.getElementById("eingabe").value);
 
   graph = board.createElement('curve', [
 
   graph = board.createElement('curve', [
             x,y,  
+
             r, [0,0],  
 
             function(){return a.Value();},  
 
             function(){return a.Value();},  
 
             function(){return b.Value();}
 
             function(){return b.Value();}
 
             ],  
 
             ],  
             {strokeColor:'red', strokeWidth:2}
+
             {curveType:'polar',strokeColor:'red', strokeWidth:2}
 
           );
 
           );
 
   board.update();
 
   board.update();
Line 52: Line 52:
 
function clearAll() {  
 
function clearAll() {  
 
   JXG.JSXGraph.freeBoard(board);
 
   JXG.JSXGraph.freeBoard(board);
   board = JXG.JSXGraph.initBoard('jxgbox', {axis:true, originX: 250, originY: 250, unitX: 50, unitY: 50});
+
   board = JXG.JSXGraph.initBoard('jxgbox', {axis:true, boundingbox: [-5, 5, 5, -5]});
 
   a = board.createElement('slider', [[0,-1],[3,-1],[-4*Math.PI,0,0]], {style:6, name:'a'});
 
   a = board.createElement('slider', [[0,-1],[3,-1],[-4*Math.PI,0,0]], {style:6, name:'a'});
   b = board.createElement('slider', [[0,-2],[3,-2],[0,1,4*Math.PI]], {style:6, name:'b'});
+
   b = board.createElement('slider', [[0,-2],[3,-2],[0,7,4*Math.PI]], {style:6, name:'b'});
 
}
 
}
  
 
plot();
 
plot();
<source>
+
</source>
  
 
[[Category:Examples]]
 
[[Category:Examples]]
 
[[Category:Calculus]]
 
[[Category:Calculus]]
 +
[[Category:Curves]]

Latest revision as of 13:22, 31 January 2013


The JavaScript code

board = JXG.JSXGraph.initBoard('jxgbox', {axis:true, boundingbox:[-5,5,5,-5]});
a = board.createElement('slider', [[0,-1],[3,-1],[-4*Math.PI,0,0]], {style:6, name:'a'});
b = board.createElement('slider', [[0,-2],[3,-2],[0,7,4*Math.PI]], {style:6, name:'b'});
function plot(){
  eval(document.getElementById("eingabe").value);
  graph = board.createElement('curve', [
            r, [0,0], 
            function(){return a.Value();}, 
            function(){return b.Value();}
            ], 
            {curveType:'polar',strokeColor:'red', strokeWidth:2}
          );
  board.update();
} 

function clearAll() { 
  JXG.JSXGraph.freeBoard(board);
  board = JXG.JSXGraph.initBoard('jxgbox', {axis:true, boundingbox: [-5, 5, 5, -5]});
  a = board.createElement('slider', [[0,-1],[3,-1],[-4*Math.PI,0,0]], {style:6, name:'a'});
  b = board.createElement('slider', [[0,-2],[3,-2],[0,7,4*Math.PI]], {style:6, name:'b'});
}

plot();