Harmonic Waves: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 9: | Line 9: | ||
board1.createElement('axis', [[0,0], [1,0]], {}); | board1.createElement('axis', [[0,0], [1,0]], {}); | ||
board1.createElement('axis', [[0,0], [0,1]], {}); | board1.createElement('axis', [[0,0], [0,1]], {}); | ||
var s = board1.createElement('slider', [[0.75,-2],[4.5,-2],[0,0,10]], {name:'S'}); | var s = board1.createElement('slider', [[0.75,-2],[4.5,-2],[0,0,10]], {name:'S',snapWidth:1}); | ||
board1.createElement('functiongraph', [ | board1.createElement('functiongraph', [ | ||
function(t) { | function(t) { | ||
var val = 0; | var val = 0; | ||
var k = 1; | var k = 1; | ||
for(var i = 0; i < | for(var i = 0; i < s.Value() + 1; i++) { | ||
val = val + Math.sin(2*Math.PI*k*t)/k; | val = val + Math.sin(2*Math.PI*k*t)/k; | ||
k += 1; | k += 1; | ||
Line 25: | Line 25: | ||
var val = 0; | var val = 0; | ||
var k = 1; | var k = 1; | ||
for(var i = 0; i < | for(var i = 0; i < s.Value() + 1; i++) { | ||
val = val + Math.sin(2*Math.PI*(2*k-1)*t)/(2*k-1); | val = val + Math.sin(2*Math.PI*(2*k-1)*t)/(2*k-1); | ||
k += 1; | k += 1; | ||
Line 41: | Line 41: | ||
board1.createElement('axis', [[0,0], [1,0]], {}); | board1.createElement('axis', [[0,0], [1,0]], {}); | ||
board1.createElement('axis', [[0,0], [0,1]], {}); | board1.createElement('axis', [[0,0], [0,1]], {}); | ||
var s = board1.createElement('slider', [[0.75,-2],[4.5,-2],[0,0,10]], {name:'S'}); | var s = board1.createElement('slider', [[0.75,-2],[4.5,-2],[0,0,10]], {name:'S',snapWidth:1}); | ||
board1.createElement('functiongraph', [ | board1.createElement('functiongraph', [ | ||
function(t) { | function(t) { | ||
var val = 0; | var val = 0; | ||
var k = 1; | var k = 1; | ||
for(var i = 0; i < | for(var i = 0; i < s.Value() + 1; i++) { | ||
val = val + Math.sin(2*Math.PI*k*t)/k; | val = val + Math.sin(2*Math.PI*k*t)/k; | ||
k += 1; | k += 1; | ||
Line 57: | Line 57: | ||
var val = 0; | var val = 0; | ||
var k = 1; | var k = 1; | ||
for(var i = 0; i < | for(var i = 0; i < s.Value() + 1; i++) { | ||
val = val + Math.sin(2*Math.PI*(2*k-1)*t)/(2*k-1); | val = val + Math.sin(2*Math.PI*(2*k-1)*t)/(2*k-1); | ||
k += 1; | k += 1; |
Revision as of 17:03, 22 June 2009
board1 = JXG.JSXGraph.initBoard('jxgbox1', {originX: 300, originY: 200, unitX: 50, unitY: 50});
board1.suspendUpdate();
board1.createElement('axis', [[0,0], [1,0]], {});
board1.createElement('axis', [[0,0], [0,1]], {});
var s = board1.createElement('slider', [[0.75,-2],[4.5,-2],[0,0,10]], {name:'S',snapWidth:1});
board1.createElement('functiongraph', [
function(t) {
var val = 0;
var k = 1;
for(var i = 0; i < s.Value() + 1; i++) {
val = val + Math.sin(2*Math.PI*k*t)/k;
k += 1;
}
return val+2;
}, -10, 10], {strokeColor: "#bb0000"});
board1.createElement('functiongraph', [
function(t) {
var val = 0;
var k = 1;
for(var i = 0; i < s.Value() + 1; 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();