Difference between revisions of "Catmull-Rom splines"

From JSXGraph Wiki
Jump to navigationJump to search
(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; for (i=0;i<5;i++) { //p.push(...")
 
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
  
 
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}));
p.push(brd.create('point', [2,2*i-1],{withLabel:true}));
 
 
}
 
}
var c = brd.create('curve', JXG.Math.Numerics.CatmullRomSpline(p), {strokeWidth:3});
+
c = brd.create('curve', JXG.Math.Numerics.CatmullRomSpline(p), {strokeWidth:3});
 
</jsxgraph>
 
</jsxgraph>
  
 
===The underlying JavaScript code===
 
===The underlying JavaScript code===
 
<source lang="javascript">
 
<source lang="javascript">
 +
var brd = JXG.JSXGraph.initBoard('box', {axis:true, boundingbox: [-5, 5, 5, -5]}),
 +
    p = [], c, i;
 +
 +
for (i=0;i<5;i++) {
 +
    p.push(brd.create('point', [(Math.random()-0.5)*7,(Math.random()-0.5)*7],{withLabel:true}));
 +
}
 +
c = brd.create('curve', JXG.Math.Numerics.CatmullRomSpline(p), {strokeWidth:3});
 
</source>
 
</source>
  
 
[[Category:Examples]]
 
[[Category:Examples]]
[[Category:Calculus]]
+
[[Category:Curves]]
 +
[[Category:Interpolation]]

Latest revision as of 14:11, 22 June 2012

The underlying JavaScript code

var brd = JXG.JSXGraph.initBoard('box', {axis:true, boundingbox: [-5, 5, 5, -5]}),
    p = [], c, i;

for (i=0;i<5;i++) {
    p.push(brd.create('point', [(Math.random()-0.5)*7,(Math.random()-0.5)*7],{withLabel:true}));
}
c = brd.create('curve', JXG.Math.Numerics.CatmullRomSpline(p), {strokeWidth:3});