Superformula: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
(10 intermediate revisions by 2 users not shown)
Line 5: Line 5:
In polar coordinates, with r the radius and φ the angle, the superformula is:
In polar coordinates, with r the radius and φ the angle, the superformula is:


: <math>
r\left(\phi\right) = \left[ \left| \frac{\cos\left(\frac{m\phi}{4}\right)}{a} \right| ^{n_{2}} + \left| \frac{\sin\left(\frac{m\phi}{4}\right)}{b} \right| ^{n_{3}} \right] ^{-\frac{1}{n_{1}}}
r\left(\phi\right) = \left[ \left| \frac{\cos\left(\frac{m\phi}{4}\right)}{a} \right| ^{n_{2}} + \left| \frac{\sin\left(\frac{m\phi}{4}\right)}{b} \right| ^{n_{3}} \right] ^{-\frac{1}{n_{1}}}
</math>


<jsxgraph width="500" height="500" box="box2">
<jsxgraph width="550" height="500" box="box2">
var b2 = JXG.JSXGraph.initBoard('box2', {axis:true,originX: 250, originY: 250, unitX: 25, unitY: 25});
var b2 = JXG.JSXGraph.initBoard('box2', {axis:true, boundingbox: [-10, 10, 12, -10]});
var a = b2.createElement('slider', [[1,8],[5,8],[0,1,4]],{name:'a'});
b2.suspendUpdate();
var b = b2.createElement('slider', [[1,7],[5,7],[0,1,4]],{name:'b'});
var a = b2.create('slider', [[-7,8],[7,8],[0,1,4]],{name:'a'});
var m = b2.createElement('slider', [[1,6],[5,6],[0,4,100]],{name:'m'});
var b = b2.create('slider', [[-7,7],[7,7],[0,1,4]],{name:'b'});
var n1 = b2.createElement('slider', [[1,5],[5,5],[0,4,40]],{name:'n_1'});
var m = b2.create('slider', [[-7,6],[7,6],[0,4,40]],{name:'m'});
var n2 = b2.createElement('slider', [[1,4],[5,4],[0,4,40]],{name:'n_2'});
var n1 = b2.create('slider', [[-7,5],[7,5],[0,4,20]],{name:'n_1'});
var n3 = b2.createElement('slider', [[1,3],[5,3],[0,4,40]],{name:'n_3'});
var n2 = b2.create('slider', [[-7,4],[7,4],[0,4,20]],{name:'n_2'});
var len = b2.createElement('slider', [[1,2],[5,2],[0,2,2]],{name:'len'});  
var n3 = b2.create('slider', [[-7,3],[7,3],[0,4,20]],{name:'n_3'});
var c = b2.createElement('curve', [
var len = b2.create('slider', [[1,2],[7,2],[0,2,20]],{name:'len'});  
         function(phi){return b2.pow(
var c = b2.create('curve', [
                              b2.pow(Math.abs(Math.cos( m.Value()*phi*0.25/a.Value() )),n2.Value())+
         function(phi){return JXG.Math.pow(
                              b2.pow(Math.abs(Math.sin( m.Value()*phi*0.25/b.Value() )),n3.Value()),
                            JXG.Math.pow(Math.abs(Math.cos( m.Value()*phi*0.25/a.Value() )), n2.Value())+
                            JXG.Math.pow(Math.abs(Math.sin( m.Value()*phi*0.25/b.Value() )), n3.Value()),
                             -1/n1.Value()); },  
                             -1/n1.Value()); },  
         [0, 0],0, function(){return len.Value()*Math.PI;}],
         [0, 0],0, function(){return len.Value()*Math.PI;}],
         {curveType:'polar', strokewidth:1,fillColor:'#765412',fillOpacity:0.6});       
         {curveType:'polar', strokewidth:1,fillColor:'#765412',fillOpacity:0.3});       
b2.unsuspendUpdate();
</jsxgraph>
</jsxgraph>


===The JavaScript code to produce this picture===
===The JavaScript code to produce this picture===
<source lang="xml">
<source lang="javascript">
var b2 = JXG.JSXGraph.initBoard('box2', {axis:true,originX: 250, originY: 250, unitX: 25, unitY: 25});
var b2 = JXG.JSXGraph.initBoard('box2', {axis:true, boundingbox: [-10, 10, 12, -10]});
var a = b2.createElement('slider', [[1,8],[5,8],[0,1,4]],{name:'a'});
b2.suspendUpdate();
var b = b2.createElement('slider', [[1,7],[5,7],[0,1,4]],{name:'b'});
var a = b2.create('slider', [[-7,8],[7,8],[0,1,4]],{name:'a'});
var m = b2.createElement('slider', [[1,6],[5,6],[0,4,20]],{name:'m'});
var b = b2.create('slider', [[-7,7],[7,7],[0,1,4]],{name:'b'});
var n1 = b2.createElement('slider', [[1,5],[5,5],[0,4,20]],{name:'n_1'});
var m = b2.create('slider', [[-7,6],[7,6],[0,4,40]],{name:'m'});
var n2 = b2.createElement('slider', [[1,4],[5,4],[0,4,20]],{name:'n_2'});
var n1 = b2.create('slider', [[-7,5],[7,5],[0,4,20]],{name:'n_1'});
var n3 = b2.createElement('slider', [[1,3],[5,3],[0,4,20]],{name:'n_3'});
var n2 = b2.create('slider', [[-7,4],[7,4],[0,4,20]],{name:'n_2'});
var len = b2.createElement('slider', [[1,2],[5,2],[0,2,2]],{name:'len'});  
var n3 = b2.create('slider', [[-7,3],[7,3],[0,4,20]],{name:'n_3'});
var c = b2.createElement('curve', [
var len = b2.create('slider', [[1,2],[7,2],[0,2,20]],{name:'len'});  
         function(phi){return b2.pow(
var c = b2.create('curve', [
                              b2.pow(Math.abs(Math.cos( m.Value()*phi*0.25/a.Value() )),n2.Value())+
         function(phi){return JXG.Math.pow(
                              b2.pow(Math.abs(Math.sin( m.Value()*phi*0.25/b.Value() )),n3.Value()),
                            JXG.Math.pow(Math.abs(Math.cos( m.Value()*phi*0.25/a.Value() )), n2.Value())+
                            JXG.Math.pow(Math.abs(Math.sin( m.Value()*phi*0.25/b.Value() )), n3.Value()),
                             -1/n1.Value()); },  
                             -1/n1.Value()); },  
         [0, 0],0, function(){return len.Value()*Math.PI;}],
         [0, 0],0, function(){return len.Value()*Math.PI;}],
         {curveType:'polar', strokewidth:1,fillColor:'#765412',fillOpacity:0.6});       
         {curveType:'polar', strokewidth:1,fillColor:'#765412',fillOpacity:0.3});       
b2.unsuspendUpdate();
</source>
</source>



Latest revision as of 16:01, 20 February 2013

The superformula is a generalization of the superellipse and was first proposed by Johan Gielis.

Gielis suggested that the formula can be used to describe many complex shapes and curves that are found in nature. Others point out that the same can be said about many formulas with a sufficient number of parameters.

In polar coordinates, with r the radius and φ the angle, the superformula is:

[math]\displaystyle{ r\left(\phi\right) = \left[ \left| \frac{\cos\left(\frac{m\phi}{4}\right)}{a} \right| ^{n_{2}} + \left| \frac{\sin\left(\frac{m\phi}{4}\right)}{b} \right| ^{n_{3}} \right] ^{-\frac{1}{n_{1}}} }[/math]

The JavaScript code to produce this picture

var b2 = JXG.JSXGraph.initBoard('box2', {axis:true, boundingbox: [-10, 10, 12, -10]});
b2.suspendUpdate();
var a = b2.create('slider', [[-7,8],[7,8],[0,1,4]],{name:'a'});
var b = b2.create('slider', [[-7,7],[7,7],[0,1,4]],{name:'b'});
var m = b2.create('slider', [[-7,6],[7,6],[0,4,40]],{name:'m'});
var n1 = b2.create('slider', [[-7,5],[7,5],[0,4,20]],{name:'n_1'});
var n2 = b2.create('slider', [[-7,4],[7,4],[0,4,20]],{name:'n_2'});
var n3 = b2.create('slider', [[-7,3],[7,3],[0,4,20]],{name:'n_3'});
var len = b2.create('slider', [[1,2],[7,2],[0,2,20]],{name:'len'}); 
var c = b2.create('curve', [
        function(phi){return JXG.Math.pow(
                             JXG.Math.pow(Math.abs(Math.cos( m.Value()*phi*0.25/a.Value() )), n2.Value())+
                             JXG.Math.pow(Math.abs(Math.sin( m.Value()*phi*0.25/b.Value() )), n3.Value()),
                             -1/n1.Value()); }, 
        [0, 0],0, function(){return len.Value()*Math.PI;}],
        {curveType:'polar', strokewidth:1,fillColor:'#765412',fillOpacity:0.3});      
b2.unsuspendUpdate();

External links