Welcome to Fractal Forums

Fractal Software => 3D Fractal Generation => Topic started by: Daniel_P on October 11, 2012, 05:03:02 PM




Title: 4D Julia / 3-sphere intersection
Post by: Daniel_P on October 11, 2012, 05:03:02 PM
It's been a while since I visited, but I wanted to share something I recently generated.
It's an idea I was talking about 3 years ago, but I finally tried it out!
Basically using an inverse stereographic projection to find for each point in 3d space a corresponding point on the 3-sphere, then evaluate the 4D julia set at this point to see whether the point in 3d space is in the set.
I'm then either rendering the point cloud or taking an isosurface.
The results seem a bit different from what you get by just intersecting flat planes.
I also tried it out with a few different powers. One could also vary the radius or position of the 3-sphere.
(http://api.ning.com/files/olqv*XgOGK-DWuJz5Xt4YL6neITnpxmd4fJfZKGkkuuTUcyj38VMnJn68SRxri8FXXbFrI2K3eavghIqvxHCyG8LmovFcv4b/mandel3d_01.jpg)
(http://api.ning.com/files/UdqLCOFrmrLMI6Eylq722aF3n4yjjVzccZXOM*qZH5UACJzKhMYiuDg89fcL0W4-Oh*AoLpo5UbYM9G-cM69RXeBgXS*bCSJ/mandel3d_pow4_iter2.jpg)
(http://api.ning.com/files/pFaL6m*Zw5I3S5DsGU0W9psz75c-YUt92Gv2ADjwB7pAkFP*wpUlk3nJNVZj5l*xNHnHzDSLJYkrXW3hCvDSBdK8YTTi2Boi/mandel3d_pow3_iter3.jpg)

These are all with fairly low resolution and numbers of iterations, because the way I was generating them is very slow, as it needs to calculate the value for every point in 3d space (I'm using Rhino3d and Grasshopper). I was wondering if one of you could find a way to render these more efficiently


Title: Re: 4D Julia / 3-sphere intersection
Post by: hobold on October 11, 2012, 08:23:54 PM
These do look interesting. I am unsure if this method will reveal anything truly new about the 4D Julia sets, though. A sphere is not flat, but it is approximated reasonably well around a given point by its tangent (hyper-)plane. Still, this is worth trying to get a better feel for the overall 4-dimensional set!


Title: Re: 4D Julia / 3-sphere intersection
Post by: Syntopia on October 12, 2012, 07:56:36 PM
Interesting idea.

I tried it out in Fragmentarium. If I understand correctly you take a point, and apply an inverse stereographic projection, like:

Code:
// Mul = 2 is standard stereographic projection
uniform float Mul; slider[0,2,3]
vec4 stereographic3Sphere(vec3 p) {
float n = dot(p,p)+1.;
return vec4(Mul*p,n-2.)/n;
}

Then I used the standard Quaternion Julia power-2 formula (QuaternionJulia.frag).

I got these images:
(http://blog.hvidtfeldts.net/media/sq 1.jpg)

(http://blog.hvidtfeldts.net/media/sq2.jpg)

(http://blog.hvidtfeldts.net/media/sq3.jpg)

(http://blog.hvidtfeldts.net/media/sq4.jpg)

I think your images look different?

Would you mind posting the 3-sphere projection formula you use and the 4D julia for the middle image (the black and white) one - then I could compare.


Title: Re: 4D Julia / 3-sphere intersection
Post by: Daniel_P on October 12, 2012, 11:54:21 PM
Hi there,

Your images are interesting, but they do look like something different than mine...
This is what I use for the inverse stereographic projection:

a  = 2 * x / (1 + x * x + y * y + z * z);
b  = 2 * y / (1 + x * x + y * y + z * z);
c  = 2 * z / (1 + x * x + y * y + z * z);
d = (-1 + x * x + y * y + z * z) / (1 + x * x + y * y + z * z);

then I take the 2 complex numbers

Z = a+bi
C = c+di

and do the usual iteration of Z = Z^2 + C
(or actually, Z^4 + C, and Z^3 + C in my second and 3rd images respectively)


Title: Re: 4D Julia / 3-sphere intersection
Post by: Syntopia on October 13, 2012, 09:27:38 AM
Ah.

We do the same stereographic projection, but then I test the 4D coordinates in a standard Quaternion Julia setup (where the Julia constant is a free parameter).

I just assumed that by '4D Julia', you meant Quaternion algebra.

I'll try out the 2D version when I get some time.


Title: Re: 4D Julia / 3-sphere intersection
Post by: DarkBeam on October 13, 2012, 11:59:56 AM
Looks cool, not so fractal but cool. :beer:


Title: Re: 4D Julia / 3-sphere intersection
Post by: Syntopia on October 13, 2012, 11:58:08 PM
I tried with your approach (using complex numbers).
My images are still a bit different, though. How many iterations do you use? You don't add any offsets?

Power 2:
(http://blog.hvidtfeldts.net/media/sc1.jpg)
Power 3:
(http://blog.hvidtfeldts.net/media/sc2.jpg)
Power 4:
(http://blog.hvidtfeldts.net/media/sc3.jpg)
with offset:
(http://blog.hvidtfeldts.net/media/sc4.jpg)
Power 8 with offset:
(http://blog.hvidtfeldts.net/media/sc5.jpg)

I use the following code:

Code:
#include "IBL-Raytracer.frag"
#include "complex.frag"
#group 2D Steregraphic Julia

uniform int Iterations;  slider[0,16,100]
uniform float Threshold; slider[0,10,100]
uniform float Power; slider[-2,2,12]
uniform vec4 Offset; slider[(-1,-1,-1,-1),(0,0,0,0),(1,1,1,1)]

vec4 stereographic3Sphere(vec3 p) {
float n = dot(p,p)+1.;
return vec4(2.*p,n-2.)/n;
}

float DE(vec3 pos) {
vec4 p4 = stereographic3Sphere(pos)+Offset;
vec2 p = p4.xy;
vec2 c = p4.zw;
float dp = 1.0;
for (int i = 0; i < Iterations; i++) {
dp =  pow( length(p), Power-1.0)*Power*dp + 1.0;
p = cPower(p,Power)+c;
if (dot(p,p) > Threshold) break;
}
float r = length(p);
return  0.5 * r * log(r) / abs(dp);
}



Title: Re: 4D Julia / 3-sphere intersection
Post by: Daniel_P on October 14, 2012, 01:19:16 AM
Wow - these are looking good!
thanks for sharing.

In the images I posted I think the number of iterations I used was always between 3 and 6

I didn't use what I would think of as an offset, but maybe it is equivalent - I was taking the modulus of the result at each point as a 3d scalar field, then taking an isosurface of that. I chose the threshold value for this isosurface just depending on what I thought looked interesting (usually I think between 0.5 and 1)