Logo by HPDZ - 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. April 23, 2024, 08:37:19 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]   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: Log spiral DE in a simple way  (Read 700 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: September 17, 2013, 06:59:16 PM »

I think this can be somewhat useful for a 3D extension grin

Attached an evaldraw screenshot.

I was wondering about a coordinate system. Ideas?  shocked

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 grin

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

Enjoy!!!


* evalspi.GIF (170.85 KB, 818x646 - viewed 66 times.)
Logged

No sweat, guardian of wisdom!
knighty
Fractal Iambus
***
Posts: 819


« Reply #1 on: October 04, 2013, 10:23:55 PM »

 cheesy
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.
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #2 on: October 05, 2013, 11:00:48 AM »

 grin I cannot wait to try it in MB. Too bad you used too many temp vars, I must dramatically cut! cry I will see police
Logged

No sweat, guardian of wisdom!
knighty
Fractal Iambus
***
Posts: 819


« Reply #3 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);
}


* spigri.jpg (49.59 KB, 400x300 - viewed 185 times.)
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #4 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 A Beer Cup
Logged

No sweat, guardian of wisdom!
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #5 on: October 07, 2013, 06:49:25 PM »

cheesy I made a trasform using your whippin' formulas. More stuffy stuff 2 come


* lsp2.GIF (95.15 KB, 858x714 - viewed 59 times.)
Logged

No sweat, guardian of wisdom!
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Simple 2D IFS animation Movies Showcase (Rate My Movie) David Makin 0 1983 Last post December 09, 2006, 11:41:48 PM
by David Makin
Simple 3D IFS in POV-Ray IFS - Iterated Function Systems utak3r 1 8472 Last post March 19, 2010, 08:16:44 AM
by Nahee_Enterprises
Plain and Simple Mandelbulb3D Gallery lenord 0 1182 Last post February 27, 2011, 07:14:47 PM
by lenord
Antenna Simple FractalForums.com Banner Logos The Rev 0 2194 Last post March 13, 2011, 07:29:13 AM
by The Rev
I think i have a simple problem Other / General Discussion veniema 3 4359 Last post February 20, 2014, 07:46:16 PM
by veniema

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.169 seconds with 24 queries. (Pretty URLs adds 0.025s, 2q)