Add spherical inversion to any 3D fractal

  • 2 Replies
  • 65 Views

0 Members and 1 Guest are viewing this topic.

Offline kosalos

  • *
  • Fractal Friar
  • *
  • Posts: 127
« on: June 30, 2020, 07:44:42 PM »
1. rename your current DE() routine to DEInner()
2. use the following as your DE().
   (this is Apple Metal code, but you get the idea)


bool    control.doInversion
float3  control.InvCenter  // each field -5 ... 5
float    control.InvRadius  // 0.01 ... 10
float    control.InvAngle   // -10 ... 10


float DE(float3 pos,device Control &control,thread float4 &orbitTrap) {
    if(control.doInversion) {
        pos = pos - control.InvCenter;
        float r = length(pos);
        float r2 = r*r;

        pos = (control.InvRadius * control.InvRadius / r2 ) * pos + control.InvCenter;
       
        float an = atan2(pos.y,pos.x) + control.InvAngle;
        float ra = sqrt(pos.y * pos.y + pos.x * pos.x);

        pos.x = cos(an)*ra;
        pos.y = sin(an)*ra;

        float de = DE_Inner(pos,control,orbitTrap);

        de = r2 * de / (control.InvRadius * control.InvRadius + r * de);
        return de;
    }
   
    return DE_Inner(pos,control,orbitTrap);
}

// image is Apollonian after inversion

Linkback: https://fractalforums.org/programming/11/add-spherical-inversion-to-any-3d-fractal/3633/

Offline 3DickUlus

  • *
  • 3f
  • ******
  • Posts: 1708
    • Digilantism
« Reply #1 on: July 01, 2020, 01:30:08 AM »
is that like...

Code: [Select]
// Roquen's domain mash up coordinate to invert to infinity
uniform vec3 InvertC; slider[(-5,-5,-5),(0,0,0),(5,5,5)]
// http://www.fractalforums.com/index.php?topic=16963.msg65053#msg65053
// performs the active c = T(s)
vec3 domainMap(vec3 c)
{
  float s = dot(c,c);
  return c/s + InvertC;
}

...or... from KleinBrot-SphereFold.frag
Code: [Select]
//Want do do an inversion
uniform bool DoInversion; checkbox[false]
//Inversion center
uniform vec3 InvCenter; slider[(-1,-1,-1),(0,0,0),(1,1,1)]
//Inversion radius squared
uniform float InvRadius;  slider[0.01,1,2]
//Recenter
uniform vec3 ReCenter; slider[(-5,-5,-5),(0,0,0),(5,5,5)]

float DE(vec3 p) {
if(DoInversion){
p=p-InvCenter-ReCenter;
float r=length(p);
float r2=r*r;
p=(InvRadius * InvRadius/r2)*p+InvCenter;
float de=DE1(p);
de=r2*de/(InvRadius * InvRadius+r*de);
return de;
}
else return DE1(p);
}
« Last Edit: July 01, 2020, 02:20:00 AM by 3DickUlus »

Offline mclarekin

  • *
  • Fractal Freak
  • **
  • Posts: 752
« Reply #2 on: July 01, 2020, 09:53:11 AM »
it is the standard sphere inversion BUT has a rotation included


Code: [Select]

      float an = atan2(pos.y,pos.x) + control.InvAngle;
        float ra = sqrt(pos.y * pos.y + pos.x * pos.x);

        pos.x = cos(an)*ra;
        pos.y = sin(an)*ra;


clip
Jos Leys' Kleinian + Spherical Inversion

Started by kosalos on Fractal Image Gallery

3 Replies
369 Views
Last post May 10, 2019, 09:36:05 PM
by gerson
clip
Knighty's Klienian + Spherical Inversion

Started by kosalos on Fractal Image Gallery

1 Replies
250 Views
Last post May 10, 2019, 09:27:05 PM
by gerson
xx
To Spherical And Back

Started by freakiebeat on Fractal movie gallery

0 Replies
114 Views
Last post March 13, 2019, 02:09:53 PM
by freakiebeat
xx
Iteration color - spherical fold

Started by mclarekin on Color Snippets

0 Replies
103 Views
Last post March 21, 2019, 09:13:57 AM
by mclarekin
xx
360 spherical movie with stereoscopic view?

Started by jan_m on Fractal movie gallery

0 Replies
37 Views
Last post May 21, 2020, 12:19:27 AM
by jan_m