Logo by Fiery - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Check out the originating "3d Mandelbulb" thread here
 
*
Welcome, Guest. Please login or register. March 28, 2024, 04:27:43 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1] 2 3 ... 7   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Cross Menger!? Can anyone do this?  (Read 17439 times)
0 Members and 1 Guest are viewing this topic.
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« on: June 11, 2016, 09:45:02 AM »

Looks very amazing!

http://paulbourke.net/fractals/crossmenger/

Can you do this fractal for Fragmentarium too? Using a KIFS routine ofc! Must be interesting as it mixes geometries
« Last Edit: June 11, 2016, 01:32:59 PM by DarkBeam » Logged

No sweat, guardian of wisdom!
Max Sinister
Conqueror
*******
Posts: 114


« Reply #1 on: June 13, 2016, 07:24:29 PM »

It's not exactly the same, but I programmed the half Menger sponge as a 3D printable file, here:
https://www.shapeways.com/shops/fractals-procgen
Logged

knighty
Fractal Iambus
***
Posts: 819


« Reply #2 on: June 22, 2016, 01:45:12 AM »

Hi,
Not eazy Sceptical

Code:
#info CrossMenger
#include "DE-Raytracer.frag"
#group CrossMenger

// Number of fractal iterations.
uniform int Iterations;  slider[0,3,100]
uniform float Gap; slider[0.,1.,1.]
uniform bool KIFS; checkbox[false]

float baseshape(vec3 p, float s){
p.yz=abs(p.yz);   
float t = 2. * max(0., dot(p.xy, vec2(-sqrt(3.) * 0.5, 0.5)) );
      p.xy -= t*vec2(-sqrt(3.),1.)*0.5;
p.y=abs(p.y);
if(p.y>p.z) p.yz=p.zy;
p-=s*vec3(0.5*sqrt(3.),1.5,1.5);
if(p.z>p.x){p.xz=p.zx;}
if(p.x<0.) return p.x;
p.yz=max(vec2(0.),p.yz);
return length(p);
}

float CrossMengerTrick(vec3 p){//use Msltoe's method. Gives correct result but the DE is discontinuous
float dd=1.;
for(int i=0; i<Iterations;i++){
p.yz=abs(p.yz);
float t = 2. * max(0., dot(p.xy, vec2(-sqrt(3.) * 0.5, 0.5)) );
p.xy -= t*vec2(-sqrt(3.),1.)*0.5;
p.y=abs(p.y);

p.x-=sqrt(3.)*0.5;
     
//Choose nearest corner/edge --> to get translation symmetry
float dy=0., dz=0.;
if(p.y>0.5 && p.z>0.5){dy=1.5; dz=1.5;}
else if((p.y-1.5)*(p.y-1.5)+p.z*p.z<p.y*p.y+(p.z-1.5)*(p.z-1.5)) dy=1.5;
else dz=1.5;
     
p.y-=dy; p.z-=dz;
p*=3.;
dd*=1./3.;
p.y+=dy; p.z+=dz;
     
p.x+=sqrt(3.)*0.5;
}
return dd*baseshape(p,Gap);
}

float CrossMengerKIFS(vec3 p){//Pure KIFS... almost correct
float dd=1.;
for(int i=0; i<Iterations;i++){
p.yz=abs(p.yz);
float t = 2. * max(0., dot(p.xy, vec2(-sqrt(3.) * 0.5, 0.5)) );
p.xy -= t*vec2(-sqrt(3.),1.)*0.5;
p.y=abs(p.y);
if(p.y>p.z) p.yz=p.zy;
p.y=abs(p.y-0.5)+0.5;
p-=vec3(0.5*sqrt(3.),1.5,1.5);

p*=3.;
dd*=1./3.;
p+=vec3(0.5*sqrt(3.),1.5,1.5);
}
return dd*baseshape(p,Gap);
}

float DE(vec3 pos) {
if(KIFS) return CrossMengerKIFS(pos);
return CrossMengerTrick(pos);
}


* crosssierpinski.jpg (65.47 KB, 512x512 - viewed 564 times.)
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #3 on: June 22, 2016, 12:43:03 PM »

hehe you never fail to amaze us! Cantor Dance Cantor Dance
Logged

No sweat, guardian of wisdom!
Crist-JRoger
Fractal Fertilizer
*****
Posts: 389



WWW
« Reply #4 on: June 22, 2016, 07:18:24 PM »

Thank you very much!  smiley Rotated looks good  cheesy




Code:
#define providesInit
#include "MathUtils.frag"

uniform vec3 Rot1; slider[(-180,-180,-180),(0,0,0),(180,180,180)]
uniform vec3 Rot2; slider[(-180,-180,-180),(0,0,0),(180,180,180)]

mat3 fracRotation1;
mat3 fracRotation2;

void init() {
fracRotation1 =rotationMatrixXYZ(vec3(Rot1.x,0.0,0.0))*rotationMatrixXYZ(vec3(0.0,Rot1.y,0.0))*rotationMatrixXYZ(vec3(0.0,0.0,Rot1.z));
fracRotation2 =rotationMatrixXYZ(vec3(Rot2.x,0.0,0.0))*rotationMatrixXYZ(vec3(0.0,Rot2.y,0.0))*rotationMatrixXYZ(vec3(0.0,0.0,Rot2.z));
}

float CrossMengerTrick(vec3 p){//use Msltoe's method. Gives correct result but the DE is discontinuous
float dd=1.;
for(int i=0; i<Iterations;i++){
p.yz=abs(p.yz);
float t = 2. * max(0., dot(p.xy, vec2(-sqrt(3.) * 0.5, 0.5)) );
p.xy -= t*vec2(-sqrt(3.),1.)*0.5;
p.y=abs(p.y);

p.x-=sqrt(3.)*0.5;
     
//Choose nearest corner/edge --> to get translation symmetry
float dy=0., dz=0.;
if(p.y>0.5 && p.z>0.5){dy=1.5; dz=1.5;}
else if((p.y-1.5)*(p.y-1.5)+p.z*p.z<p.y*p.y+(p.z-1.5)*(p.z-1.5)) dy=1.5;
else dz=1.5;
p.y-=dy; p.z-=dz;

p=fracRotation1*p;

p*=3.;
dd*=1./3.;
p.y+=dy; p.z+=dz;
p.x+=sqrt(3.)*0.5;

p=fracRotation2*p;

}
return dd*baseshape(p,Gap);
}
Logged

DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #5 on: June 22, 2016, 10:09:46 PM »

Heyyy can you post a render of the kifs version? plzzz
Logged

No sweat, guardian of wisdom!
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #6 on: June 23, 2016, 12:12:00 AM »

It is  a cool  maths, and I am still far from understanding it and getting it coded.

It will be interesting to see the hybrids that can be made with it.

One question for now, what is "s" that is being brought into the baseshape?
Logged
Crist-JRoger
Fractal Fertilizer
*****
Posts: 389



WWW
« Reply #7 on: June 23, 2016, 12:47:01 AM »

Heyyy can you post a render of the kifs version? plzzz
cheesy
KIFS rotated, fullscreen super resolution mode, 3000 subframes, palette by M Benesi  smiley






Code:
float CrossMengerKIFS(vec3 p){//Pure KIFS... almost correct
float dd=1.;
for(int i=0; i<Iterations;i++){
p=fracRotation1*p;
p.yz=abs(p.yz);
float t = 2. * max(0., dot(p.xy, vec2(-sqrt(3.) * 0.5, 0.5)) );
p.xy -= t*vec2(-sqrt(3.),1.)*0.5;
p.y=abs(p.y);

if(p.y>p.z) p.yz=p.zy;
p.y=abs(p.y-0.5)+0.5;
p-=vec3(0.5*sqrt(3.),1.5,1.5);

p*=3.;
dd*=1./3.;
p+=vec3(0.5*sqrt(3.),1.5,1.5);
p=fracRotation2*p;
orbitTrap = min(orbitTrap, abs(vec4(p.xyz,dot(p,p))));
}
return dd*baseshape(p,Gap);
}
Logged

M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #8 on: June 23, 2016, 06:27:29 AM »

Sweet.  cheesy
Logged

Crist-JRoger
Fractal Fertilizer
*****
Posts: 389



WWW
« Reply #9 on: June 23, 2016, 12:02:16 PM »

It will be interesting to see the hybrids that can be made with it.
Pseudo-Kleinian hybrid looks awesome  wink
intel gpu quick render
Logged

mclarekin
Fractal Senior
******
Posts: 1739



« Reply #10 on: June 23, 2016, 12:41:41 PM »

Wow! that is beautiful.    afro
Logged
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #11 on: June 23, 2016, 02:11:30 PM »

Thanks Knighty, I have only coded the basic shape so far, and now I am sidetracked into testing it out on various formulas. afro


* crossMgr aaa2 8.jpg (117.21 KB, 800x800 - viewed 569 times.)

* crossMgr aaa1 f.jpg (100 KB, 500x500 - viewed 894 times.)
Logged
Crist-JRoger
Fractal Fertilizer
*****
Posts: 389



WWW
« Reply #12 on: June 23, 2016, 03:56:54 PM »

mclarekin, nice shapes )

so, just little fun:
Logged

knighty
Fractal Iambus
***
Posts: 819


« Reply #13 on: June 24, 2016, 02:14:34 AM »

Wow! those are awesome and really unexpected results.

FYI, The base sape is not really necessary if you use a lot of iterations. It is there only for low iteration. One can replace it with a sphere as usual.

The s parameter is there only to give the gaps and get a picture that looks like those of the OP. (just experiement with the Gap slider to see what I mean cheesy )
Logged
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #14 on: June 24, 2016, 04:33:41 AM »

Quote
Wow!
Yes that's what I have been thinking , from the time I first saw the post.

Quote
FYI, The baseshape is not really necessary if you use a lot of iterations. It is there only for low iteration. One can replace it with a sphere as usual.
So it is a pre-transform necessary for  low iteration formulas.  I did a bit of this in Mandelbulber V1.21OpenCL but we have yet to set up an "Initial Conditions" feature to easily implement pre_transforms in MandelbulberV2
 Thanks for info.

Quote
just experiment with the Gap slider
I still havent coded it yet, LOL, (I am slow and easily distracted),as the baseshape is too interesting. I have being mixing it successfully with various Abox/Mbox & menger type fractals with generally good analytic DE results.

But here a two questions.

1) Has the baseshape got a name (prism??) because I will add it as a Transform  as well as using it in a Formula UI??
 2) This bit confuses me     if(p.x<0.) return p.x;  in .frag language does it mean "if p.x is neg return as pos" same as abs?? (I am not a real programmer, just an apprentice fractal coder)
 embarrass I know the answer I just forgot LOL,  embarrass

Cheers

BTW This is a draft c++ version of the baseshape with some multiplications removed and constants added.

Code:
void CrossMengerIteration(CVector3 &z, CVector3 &c, int i, const cFractal *fractal, sExtendedAux &aux)
{
  double s = fractal->transformCommon.scale1; // find out where s comes from
  double gap = fractal->transformCommon.scale;//
  double t;
  double temp;
  double sqr3 = SQRT_3;
  double sqr305 = 0.86602540378443864676372317075294;

  if(i >= fractal->transformCommon.startIterations
     && i < fractal->transformCommon.stopIterations)  // temporary controls
  {
    z.y = fabs(z.y);
    z.z = fabs(z.z);
    double dot = z.x * -sqr305 + z.y * 0.5;
    t = max(0.0, dot); // if dot neg , t= 0
    z.x -= t * -sqr3; // z.x moves pos dir
    z.y = fabs(z.y - t);
    if(z.y > z.z) // z.z pos
    {
      temp =z.y;
      z.y = z.z;
      z.z = temp; // z.z is the biggest pos
    }
    z -= s * CVector3( sqr305, 1.5, 1.5); //  "s" scale of vec being subtracted, s  from where??
    // z was pos, now some points neg (ie neg shift)
    if(z.z > z.x)
    {
      temp =z.z;
      z.z = z.x;
      z.x = temp; // z.x is the biggest
    }
    if(z.x < 0.0 )
      z.x = -z.x; // channge to positive ???
    z.y = max(0.0, z.y);
    z.z = max(0.0, z.z);

    z = fractal->transformCommon.rotationMatrix.RotateVector(z);


* crossMgr cvb1 hybrid 9.jpg (71.43 KB, 453x467 - viewed 885 times.)
« Last Edit: June 24, 2016, 06:46:28 AM by mclarekin, Reason: Remembered what I forgot.Old tired brain. » Logged
Pages: [1] 2 3 ... 7   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
cross 2D Art ramblerette 0 1460 Last post March 29, 2009, 02:28:49 PM
by ramblerette
At the Cross Images Showcase (Rate My Fractal) John Smith 0 1103 Last post June 10, 2012, 10:43:53 PM
by John Smith
Cross JWildfire Gallery thargor6 1 805 Last post December 06, 2012, 04:04:30 AM
by Pauldelbrot
3D Printed Cross Sections of the Menger Sponge Format, Printing & Post Production tit_toinou 6 4541 Last post April 29, 2013, 03:35:56 PM
by cKleinhuis
Cross Mandelbulb3D Gallery MichaelWGioffredi 0 848 Last post April 22, 2015, 11:33:06 AM
by MichaelWGioffredi

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.372 seconds with 28 queries. (Pretty URLs adds 0.023s, 2q)