Cardinal splines: Difference between revisions
From JSXGraph Wiki
| A WASSERMANN (talk | contribs)  Created page with "jsxgraph width="400" height="400" box="box"> var brd = JXG.JSXGraph.initBoard('box', {axis:true, boundingbox: [-5, 5, 5, -5]}),     p = [], c, i, tau;  for (i=0;i<5;i++) {     p...." | A WASSERMANN (talk | contribs) No edit summary | ||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| jsxgraph width="400" height="400" box="box"> | <jsxgraph width="400" height="400" box="box"> | ||
| var brd = JXG.JSXGraph.initBoard('box', {axis:true, boundingbox: [-5, 5, 5, -5]}), | var brd = JXG.JSXGraph.initBoard('box', {axis:true, boundingbox: [-5, 5, 5, -5]}), | ||
|      p = [], c, i, tau; |      p = [], c, i, tau; | ||
| Line 7: | Line 7: | ||
| } | } | ||
| tau = brd.create('slider', [[ | // tension | ||
| tau = brd.create('slider', [[0.5,4],[3,4],[0.001,0.5,1]], {name:'tau'}); | |||
| c = brd.create('curve', JXG.Math.Numerics.CardinalSpline(p, function(){ return tau.Value();}), {strokeWidth:3}); | c = brd.create('curve', JXG.Math.Numerics.CardinalSpline(p, function(){ return tau.Value();}), {strokeWidth:3}); | ||
| </jsxgraph> | </jsxgraph> | ||
| Line 14: | Line 15: | ||
| <source lang="javascript"> | <source lang="javascript"> | ||
| var brd = JXG.JSXGraph.initBoard('box', {axis:true, boundingbox: [-5, 5, 5, -5]}), | var brd = JXG.JSXGraph.initBoard('box', {axis:true, boundingbox: [-5, 5, 5, -5]}), | ||
|      p = [], c, i; |      p = [], c, i, tau; | ||
| for (i=0;i<5;i++) { | for (i=0;i<5;i++) { | ||
|      p.push(brd.create('point', [(Math.random()-0.5)*7,(Math.random()-0.5)*7],{withLabel:true})); |      p.push(brd.create('point', [(Math.random()-0.5)*7,(Math.random()-0.5)*7],{withLabel:true})); | ||
| } | } | ||
| // tension | |||
| tau = brd.create('slider', [[0.5,4],[4,3],[0.001,0.5,1]], {name:'tau'}); | |||
| c = brd.create('curve', JXG.Math.Numerics.CardinalSpline(p, function(){ return tau.Value();}), {strokeWidth:3}); | c = brd.create('curve', JXG.Math.Numerics.CardinalSpline(p, function(){ return tau.Value();}), {strokeWidth:3}); | ||
| </source> | </source> | ||
Latest revision as of 07:55, 10 April 2014
The underlying JavaScript code
var brd = JXG.JSXGraph.initBoard('box', {axis:true, boundingbox: [-5, 5, 5, -5]}),
    p = [], c, i, tau;
for (i=0;i<5;i++) {
    p.push(brd.create('point', [(Math.random()-0.5)*7,(Math.random()-0.5)*7],{withLabel:true}));
}
// tension
tau = brd.create('slider', [[0.5,4],[4,3],[0.001,0.5,1]], {name:'tau'});
c = brd.create('curve', JXG.Math.Numerics.CardinalSpline(p, function(){ return tau.Value();}), {strokeWidth:3});
