Difference between revisions of "Polar curve plotter"

From JSXGraph Wiki
Jump to navigationJump to search
 
(One intermediate revision by one other user not shown)
Line 9: Line 9:
 
<jsxgraph width="500" height="500">
 
<jsxgraph width="500" height="500">
 
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.create('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'});
+
b = board.create('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.create('curve', [
 
             r, [0,0],  
 
             r, [0,0],  
 
             function(){return a.Value();},  
 
             function(){return a.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.create('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'});
+
   b = board.create('slider', [[0,-2],[3,-2],[0,7,4*Math.PI]], {style:6, name:'b'});
 
}
 
}
  
Line 36: Line 36:
 
<source lang="javascript">
 
<source lang="javascript">
 
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.create('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'});
+
b = board.create('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.create('curve', [
 
             r, [0,0],  
 
             r, [0,0],  
 
             function(){return a.Value();},  
 
             function(){return a.Value();},  
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.create('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'});
+
   b = board.create('slider', [[0,-2],[3,-2],[0,7,4*Math.PI]], {style:6, name:'b'});
 
}
 
}
  

Latest revision as of 15:10, 3 March 2021


The JavaScript code

board = JXG.JSXGraph.initBoard('jxgbox', {axis:true, boundingbox:[-5,5,5,-5]});
a = board.create('slider', [[0,-1],[3,-1],[-4*Math.PI,0,0]], {style:6, name:'a'});
b = board.create('slider', [[0,-2],[3,-2],[0,7,4*Math.PI]], {style:6, name:'b'});
function plot(){
  eval(document.getElementById("eingabe").value);
  graph = board.create('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.create('slider', [[0,-1],[3,-1],[-4*Math.PI,0,0]], {style:6, name:'a'});
  b = board.create('slider', [[0,-2],[3,-2],[0,7,4*Math.PI]], {style:6, name:'b'});
}

plot();