Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => (new) Theories & Research => Topic started by: DarkBeam on September 17, 2013, 06:59:16 PM




Title: Log spiral DE in a simple way
Post by: DarkBeam on September 17, 2013, 06:59:16 PM
I think this can be somewhat useful for a 3D extension ;D

Attached an evaldraw screenshot.

I was wondering about a coordinate system. Ideas?  :o

PS to get a double winding spiral, transform xy with Cayley;
cay=1/(y*y+(x-1)^2); x1=x*x+y*y-1; y1= 2*y;
y = y1*cay; x = x1*cay;

More spiral types. Istead of r=log(1*R0)-TH; type r=f(1*R0)-TH; with f = infinity at x=0 ;D

Multi-spirals. r=log(1*R0)-TH; type r=log(1*R0)-n*TH;  n=an integer. ;D

Enjoy!!!


Title: Re: Log spiral DE in a simple way
Post by: knighty on October 04, 2013, 10:23:55 PM
 :D
What about this:
Code:
/////////////////////////////////////////////////
spiral(x,y,z,nbrS,bend,Snail,rotScl,width){
   //Z=c*ln(z)+t
   //Z'=c*(ln(z))'=c/z
   //dr=|Z'|=|c|/|z|
   //DE "=" Tile1D(Im(Z),2*PI)/dr
   cx=nbrS;//number of arms of the spiral. Must be integer and !=0
   cy=bend;//Bending of the spiral
   r=sqrt(x*x+y*y); t=atan2(y,x);
   dr=sqrt(cx*cx+cy*cy)/r;
   x=log(r); y=t;
   x1=x*cx-y*cy;
   y=x*cy+y*cx+rotScl;
   DE=(Tile1D(y,2*pi))/dr;//this is approximate 2D distance estimate to the spiral
   (sqrt(((z-0)+Snail*r)^2+DE^2)-r*width)//approximate 3D DE
}
Tile1D(p, a){
  p -= a * floor(p/a);
  p -= 2.* max(p - 0.5 * a , 0.0);
  return p;
}
/////////////////////////////////////////////////

It's just an approximation.


Title: Re: Log spiral DE in a simple way
Post by: DarkBeam on October 05, 2013, 11:00:48 AM
 ;D I cannot wait to try it in MB. Too bad you used too many temp vars, I must dramatically cut! :'( I will see :police:


Title: Re: Log spiral DE in a simple way
Post by: knighty on October 05, 2013, 04:02:32 PM
Well... The code I posted is not well written and there is room for improvement and optimization. Here is the obfuscated and slightly optimized spiral function. I've removed the rotScl parameter which rotates/scales the spiral (rotating and scaling a log spiral are exactly the same operation):
Code:
#define TWOPI 2. * PI
#define ITWOPI 0.5/PI

(x,y) {
   min(spiral(x,y,0,1,10,0,0), spiral(x,y,0,-10,1,0,0))^0.25
}
spiral(x,y,z,cx,cy,Snail,width){
   r=sqrt(x*x+y*y);
   y=atan2(y,x);
   x=log(r);
   y=x*cy+y*cx;
   y -= TWOPI * floor(y * ITWOPI);
   y -= max(2. * y - TWOPI , 0.0);
   DE=y*r*1./sqrt(cx*cx+cy*cy);//1./sqrt(cx*cx+cy*cy) is constant so it should be precalculated
   return (sqrt((z+Snail*r)^2+DE^2)-r*width);
}

BTW! if you do:
Code:
    min(spiral(x,y,z,cx,cy,Snail,width), spiral(x,y,z,-cy,cx,Snail,width))
and provided that cx and cy are integers, it gives a spiral grid. Notice that vector(cx,cy) is perpendicular to vector(-cy,cx)...

Code:
//Use arrow keys to modify the grid
#define TWOPI 2. * PI
#define ITWOPI 0.5/PI
static arms=1;
static bend=10;
static IMC=0;
static width=0.025;
static snail=0;
static frm=-1;
(x,y) {
   if(frm<numframes){
      frm=numframes;
      if(keystatus[0xc8]){keystatus[0xc8]=0; arms+=1;}//up
      if(keystatus[0xd0]){keystatus[0xd0]=0; arms-=1;}//down
      if(keystatus[0xcb]){keystatus[0xcb]=0; bend+=1;}//left
      if(keystatus[0xcd]){keystatus[0xcd]=0; bend-=1;}//right
      IMC=1/sqrt(arms^2+bend^2);
   }
   min(spiral(x,y,0), ispiral(x,y,0))^0.25
}
spiral(x,y,z){
   r=sqrt(x*x+y*y);
   y=atan2(y,x);
   x=log(r);
   y=x*bend+y*arms;
   y -= TWOPI * floor(y * ITWOPI);
   y -= max(2. * y - TWOPI , 0.0);
   DE=y*r*IMC;
   return (sqrt((z+Snail*r)^2+DE^2)-r*width);
}

ispiral(x,y,z){
   r=sqrt(x*x+y*y);
   y=atan2(y,x);
   x=log(r);
   y=x*arms-y*bend;//only thing that changes
   y -= TWOPI * floor(y * ITWOPI);
   y -= max(2. * y - TWOPI , 0.0);
   DE=y*r*IMC;
   return (sqrt((z+Snail*r)^2+DE^2)-r*width);
}


Title: Re: Log spiral DE in a simple way
Post by: DarkBeam on October 07, 2013, 05:01:26 PM
If you readed my last post ignore it, I will do it on my own (I will try)

Thanks so much again Knighty :beer:


Title: Re: Log spiral DE in a simple way
Post by: DarkBeam on October 07, 2013, 06:49:25 PM
:D I made a trasform using your whippin' formulas. More stuffy stuff 2 come