Harmonic Waves: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 2: Line 2:
     board1 = JXG.JSXGraph.initBoard('jxgbox1', {axis: true, boundingbox: [-6, 5, 6, -5]});
     board1 = JXG.JSXGraph.initBoard('jxgbox1', {axis: true, boundingbox: [-6, 5, 6, -5]});
     board1.suspendUpdate();
     board1.suspendUpdate();
     var s = board1.createElement('slider', [[0.75,-2],[4.5,-2],[0,0,10]], {name:'S',snapWidth:1});
     var s = board1.create('slider', [[0.75,-2],[4.5,-2],[0,0,10]], {name:'S',snapWidth:1});
     board1.createElement('functiongraph', [
     board1.create('functiongraph', [
         function(t) {
         function(t) {
             var val = 0, sv = s.Value()+1,
             var val = 0, sv = s.Value()+1,
Line 14: Line 14:
             }, -10, 10], {strokeColor: "#bb0000"});
             }, -10, 10], {strokeColor: "#bb0000"});
      
      
         board1.createElement('functiongraph', [
         board1.create('functiongraph', [
             function(t) {
             function(t) {
             var val = 0, sv = s.Value()+1,
             var val = 0, sv = s.Value()+1,
Line 31: Line 31:
board1 = JXG.JSXGraph.initBoard('jxgbox1', {axis: true, boundingbox: [-6, 5, 6, -5]});
board1 = JXG.JSXGraph.initBoard('jxgbox1', {axis: true, boundingbox: [-6, 5, 6, -5]});
board1.suspendUpdate();
board1.suspendUpdate();
var s = board1.createElement('slider', [[0.75,-2],[4.5,-2],[0,0,10]], {name:'S',snapWidth:1});
var s = board1.create('slider', [[0.75,-2],[4.5,-2],[0,0,10]], {name:'S',snapWidth:1});
board1.createElement('functiongraph', [
board1.createElement('functiongraph', [
     function(t) {
     function(t) {
Line 43: Line 43:
     }, -10, 10], {strokeColor: "#bb0000"});
     }, -10, 10], {strokeColor: "#bb0000"});


board1.createElement('functiongraph', [
board1.create('functiongraph', [
     function(t) {
     function(t) {
         var val = 0, sv = s.Value()+1,
         var val = 0, sv = s.Value()+1,

Revision as of 07:12, 8 June 2011

board1 = JXG.JSXGraph.initBoard('jxgbox1', {axis: true, boundingbox: [-6, 5, 6, -5]});
board1.suspendUpdate();
var s = board1.create('slider', [[0.75,-2],[4.5,-2],[0,0,10]], {name:'S',snapWidth:1});
board1.createElement('functiongraph', [
    function(t) {
        var val = 0, sv = s.Value()+1,
        k = 1;
        for(var i = 0; i < sv; i++) {
            val = val + Math.sin(2*Math.PI*k*t)/k;
            k += 1;
        }
        return val+2;
    }, -10, 10], {strokeColor: "#bb0000"});

board1.create('functiongraph', [
    function(t) {
        var val = 0, sv = s.Value()+1,
            k = 1;
        for(var i = 0; i < sv; i++) {
            val = val + Math.sin(2*Math.PI*(2*k-1)*t)/(2*k-1);
            k += 1;
        }
        return val-2;
    }, -10, 10], {strokeColor: "#cc5520"});

board1.unsuspendUpdate();