Add radial symmetry to your 2D fractal

  • 2 Replies
  • 58 Views

0 Members and 1 Guest are viewing this topic.

Offline kosalos

  • *
  • Fractal Friar
  • *
  • Posts: 127
« on: June 28, 2020, 08:48:18 AM »
alter the source coordinate according to a radial angle (0.01 ... Pi) for radial symmetry

Here's the entry point to an Apple Metal shader
--------------------------------------------------------

kernel void fractalShader
(
 texture2d<float, access::write> outTexture [[texture(0)]],
 constant Control &control  [[ buffer(0) ]],
 uint2 srcP [[thread_position_in_grid]])
{
    uint2 p = srcP;                                         // copy of pixel coordinate, altered during radial symmetry
   
    // apply radial symmetry? ---------
    if(control.radialAngle > 0.01) {                 // 0 = don't apply
        float centerX = control.xSize/2;            // size of texture in pixels
        float centerY = control.ySize/2;
        float dx = float(srcP.x - centerX);
        float dy = float(srcP.y - centerY);

        float angle = fabs(atan2(dy,dx));

        float dRatio = 0.01 + control.radialAngle;
        while(angle > dRatio) angle -= dRatio;
        if(angle > dRatio/2) angle = dRatio - angle;

        float dist = sqrt(dx * dx + dy * dy);

        p.x = uint(centerX + cos(angle) * dist);
        p.y = uint(centerY + sin(angle) * dist);
    }
   
    ....  rest of shader proceeds as usual
   

Linkback: https://fractalforums.org/programming/11/add-radial-symmetry-to-your-2d-fractal/3621/

Offline Sabine62

  • *
  • 3c
  • ***
  • Posts: 805
  • It's just a jump to the left...
    • sabine62.deviantart.com
« Reply #1 on: June 28, 2020, 09:15:17 AM »
Very cool, Kosalos, symmetric polyfolding for 2D! :thumbs:

For Fragmentarium there's a 3D version in the code-snippets (one by Eiffie (ported by me) and a very elaborate one with lots of tweakability by mclarekin), if you're interested
To thine own self be true

Offline Sabine62

  • *
  • 3c
  • ***
  • Posts: 805
  • It's just a jump to the left...
    • sabine62.deviantart.com
« Reply #2 on: June 28, 2020, 10:06:54 AM »
Hm, I have just this minute got this if you just want it as pre-transform (Eiffie's code jumbled into something that seems to do the trick for 2D, not sure if it's correct, of course! ;) )

Code: [Select]
//based on Eiffie's _polyfoldsym 3D-transform

uniform bool PolyFold;checkbox[false]
uniform float PolyFoldOrder;slider[0,4,100]
uniform vec2 shiftXY;slider[(-2,-2),(0,0),(2,2)]
#define pi 3.14159

//before iteration:
        float poly=PolyFoldOrder;
poly+=0.000001; //no division by 0
if (PolyFold) {float psi = abs(mod(atan(z.x,z.y)+pi/poly,pi/(0.5*poly))-pi/poly);
z.xy=vec2(cos(psi),sin(psi))*length(z.xy);z.xy+=shiftXY;};

Edit: have tested some more and until now works well for julias
« Last Edit: June 28, 2020, 10:18:24 AM by Sabine62 »


xx
boolean symmetry

Started by mclarekin on Fractal Image Gallery

6 Replies
280 Views
Last post September 11, 2018, 04:03:16 PM
by Sabine62
xx
Triangle symmetry

Started by Nintendokater on Fractal Image Gallery

0 Replies
95 Views
Last post April 18, 2020, 05:55:11 PM
by Nintendokater
xx
Google+ series on scale symmetry

Started by TGlad on Share a fractal

1 Replies
355 Views
Last post May 15, 2018, 01:02:36 PM
by TGlad
xx
Predicting symmetry structure of 2D "hybrid" fractals

Started by greentexas on Fractal Mathematics And New Theories

0 Replies
160 Views
Last post July 18, 2018, 04:05:37 AM
by greentexas
xx
"Symmetry Unaquired"

Started by cricke49 on Fractal Image Gallery

0 Replies
101 Views
Last post May 13, 2018, 07:23:32 AM
by cricke49