P-Norm: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
function(t){ | function(t){ | ||
var p = pNorm.Value(); | var p = pNorm.Value(); | ||
return 2.0/Math.pow(Math. | return 2.0/Math.pow(Math.pow(Math.abs(Math.cos(t)),p)+ | ||
Math.pow(Math.abs(Math.sin(t)),p),1.0/p); | Math.pow(Math.abs(Math.sin(t)),p),1.0/p); | ||
}, | }, | ||
Line 23: | Line 23: | ||
function(t){ | function(t){ | ||
var p = pNorm.Value(); | var p = pNorm.Value(); | ||
return 2.0/Math.pow(Math. | return 2.0/Math.pow(Math.pow(Math.abs(Math.cos(t)),p)+ | ||
Math.pow(Math.abs(Math.sin(t)),p),1.0/p); | Math.pow(Math.abs(Math.sin(t)),p),1.0/p); | ||
}, | }, |
Latest revision as of 20:45, 1 July 2010
The underlying JavaScript code
var brd = JXG.JSXGraph.initBoard('jxgbox', {axis:true, boundingbox:[-5,5,5,-5]});
var pNorm = brd.create('slider', [[0,4],[3,4],[0,2,10]], {name:'p'});
var m = brd.create('point',[0,0], {name:'M'});
graph = brd.create('curve', [
function(t){
var p = pNorm.Value();
return 2.0/Math.pow(Math.pow(Math.abs(Math.cos(t)),p)+
Math.pow(Math.abs(Math.sin(t)),p),1.0/p);
},
[function(){ return m.X();}, function(){ return m.Y();}],
0, Math.PI*2],
{curveType:'polar',strokeColor:'red', strokeWidth:2}
);