• April 20, 2021, 08:58:23 AM

0 Members and 1 Guest are viewing this topic.

#### kosalos

• Fractal Friar
• Posts: 142
« 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
--------------------------------------------------------

(
texture2d<float, access::write> outTexture [[texture(0)]],
constant Control &control  [[ buffer(0) ]],
{
uint2 p = srcP;                                         // copy of pixel coordinate, altered during 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

#### Sabine62

• 3f
• Posts: 1182
« Reply #1 on: June 28, 2020, 09:15:17 AM »
Very cool, Kosalos, symmetric polyfolding for 2D!

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

#### Sabine62

• 3f
• Posts: 1182
« 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-transformuniform 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 »

### Similar Topics

###### boolean symmetry

Started by mclarekin on Fractal Image Gallery

6 Replies
373 Views
September 11, 2018, 04:03:16 PM
by Sabine62
###### Triangle symmetry

Started by Nintendokater on Fractal Image Gallery

0 Replies
239 Views
April 18, 2020, 05:55:11 PM
by Nintendokater
###### Baroque Symmetry

Started by ThunderboltPagoda on Fractal movie gallery

1 Replies
284 Views
July 27, 2020, 11:15:21 PM
by gerson
###### Google+ series on scale symmetry

Started by TGlad on Share a fractal

1 Replies
448 Views
May 15, 2018, 01:02:36 PM