• April 20, 2021, 09:55:31 AM

Login with username, password and session length

Author Topic:  Add radial symmetry to your 2D fractal  (Read 168 times)

0 Members and 1 Guest are viewing this topic.

Offline kosalos

  • Fractal Friar
  • *
  • Posts: 142
Add radial symmetry to your 2D fractal
« 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/index.php?topic=3621.0

Offline Sabine62

  • 3f
  • ******
  • Posts: 1182
  • It's just a jump to the left...
    • sabine62.deviantart.com
Re: Add radial symmetry to your 2D fractal
« 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

  • 3f
  • ******
  • Posts: 1182
  • It's just a jump to the left...
    • sabine62.deviantart.com
Re: Add radial symmetry to your 2D fractal
« 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
Baroque Symmetry

Started by ThunderboltPagoda on Fractal movie gallery

1 Replies
284 Views
Last post July 27, 2020, 11:15:21 PM
by gerson
xx
Triangle symmetry

Started by Nintendokater on Fractal Image Gallery

0 Replies
240 Views
Last post April 18, 2020, 05:55:11 PM
by Nintendokater
xx
boolean symmetry

Started by mclarekin on Fractal Image Gallery

6 Replies
374 Views
Last post September 11, 2018, 04:03:16 PM
by Sabine62
xx
Google+ series on scale symmetry

Started by TGlad on Share a fractal

1 Replies
450 Views
Last post May 15, 2018, 01:02:36 PM
by TGlad
xx
My new book is out! Exploring Scale Symmetry

Started by TGlad on Announcements and News

15 Replies
862 Views
Last post March 30, 2021, 05:35:43 AM
by 1Maniac