Suitable C pseudo code could be:
float r = pow(pow(fabs(cos(m * o / 4)) / a, n2) + pow(fabs(sin(m * o / 4)) / b, n3), 1 / n1);
The result of this calculation is in polar coordinates. Please note the difference between the equation and the C code. The equation has a negative power value, the C doesn't. To extend this result into 3D, the spherical product of several superformulas is used. For example, the 3D parametric surface is obtained multiplying two superformulas S1and S2. The coordinates are defined by the relations:
The sphere mapping code uses two r values:
point->x = (float)(cosf(t) * cosf(p) / r1 / r2);point->y = (float)(sinf(t) * cosf(p) / r1 / r2);
point->z = (float)(sinf(p) / r2);
Because r1 and r2 had a positive power value in the C code above we have to divide by those variables here. Here is a Mathematica render of this code:
the jet.ro/creations URL has an extra space in it between / and creations so doesn't work.
ReplyDeletei love playing around this these types of constructs btw... i'm assuming much like many other graphics programmers... they represent a staple "geometry" library when faced with testing without an artist as a guinea pig
Thanks! Fixed it.
ReplyDeleteI am actually more fascinated by the look of the 3D Supershape objects ... they look so cool that I want to use this for a game or a demo :-) ... at some point.
ReplyDeleteThere's a wealth of information like this on paul's site.
ReplyDeletesounds like its time for you to join the demoscene, wolfgang!
This is why I referred to it.
ReplyDeleteAny chance to see you at a demoparty or have you been to one yet?
ReplyDeleteSomehow its kinda weird. I was always interested in GTA and found out that you were a graphics developer at R* after reading (and liking) your posts at gamedev. Then I got interested in the demoscene and saw you posting San Angelos for the iPhone. Now you got a Beagle Board, only half a year after I got mine in preparation for the Pandora. :P
PS: Did you also pre-order a Pandora btw?
Yep I also ordered the Pandora ... no I won't be on a demoparty but on SIGGRAPH :-)
ReplyDeleteYou can also apply the same formula to a toroid, for cool variations.
ReplyDeletehttp://machinesdontcare.wordpress.com/2008/11/08/superformula-toroidal-mapping/
I adapted my code from HLSL shader code written for the realtime graphics application VVVV. You might want to check out the vvvv site, it's got some nice stuff there, and has been a real source of inspiration (and code) for me for a few years now.
a|x
I don't suppose you still have the Mathematica code for this?
ReplyDeleteI was looking for this two weeks ago. It got lost in a hard drive melt of my backup system in 2010 ...
ReplyDelete