Arc length: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 41: | Line 41: | ||
brd.createElement('text',[-6,-1,function(){ return 'Length='; }]); | brd.createElement('text',[-6,-1,function(){ | ||
var i,s,f0,f1; | |||
var m = n.Value(); | |||
m = Math.floor(m); | |||
var d = (end-start)/m; | |||
s = 0.0; | |||
f0 = f(start); | |||
for (i=1;i<=m;i++) { | |||
f1 = f(start+i*d); | |||
s += Math.sqrt(d*d+(f1-f0)*(f1-f0)); | |||
f0 = f1; | |||
} | |||
return 'Length='+s.toFixed(2); }]); | |||
</jsxgraph> | </jsxgraph> | ||