POV-Ray : Newsgroups : povray.binaries.images : Fractal weirdness : Fractal weirdness Server Time
30 Jul 2024 14:22:28 EDT (-0400)
  Fractal weirdness  
From: Anthony D  Baye
Date: 19 Jun 2011 14:10:01
Message: <web.4dfe3ab2dc4f47629c4fb0ad0@news.povray.org>
I've been toying around with fractals again.  My latest investigation is the
Gosper Island.  I had been thinking of using the fractal as a tile, but I'm
having trouble locating the center.

I'm using my logo macros to generate the fractal.  The file is included below.

#macro triline2(len, epsilon)

#if(len < epsilon)
    fd(len)
#else
    lt(acos(5 * sqrt(7) / 14))
    triline2(len/sqrt(7), epsilon)
    rt(60)
    triline2(len/sqrt(7), epsilon)
    lt(60)
    triline2(len/sqrt(7), epsilon)
    rt(acos(5 * sqrt(7) / 14))
#end

#end

// Gosper fractal can tile the plane
#macro Gosper(len, epsilon)

#local a = 0;
#while(a < 6)
    triline2(len, epsilon)
    lt(60)
#local a = a + 1;
#end

#end

init()
Gosper(2, 0.01)

The problem is that as epsilon gets smaller, the fractal seems to rotate about
the origin, and I'm not sure why.  I don't have the time to dig through the
calculations, but I suspect that it has to do with where the recursion stops.

If anyone can help, I'd appreciate it.

Regards,

A.D.B.

P.S: as a side note, it might be neat to have some of these fractals like the
Koch flake and the Gosper island available as patterns in a later version...

/* ! ----- Begin koch.pov ----- ! */
#include "kolors.inc"
#include "math.inc"

light_source { -50.0*z, color rgb 1 }
camera {
     orthographic
     location <0.0, 0.0, -10.0>
     look_at 0.0
     }

#macro init()
#declare _cP_ = <0.0, 0.0, 0.0>;
#declare _cD_ = 0;
#declare _DRAW_ = true;
#declare _INIT_ = 1;
#end

// Pen Up
#macro pu()
     #declare _DRAW_ = false;
#end

// Pen Down
#macro pd()
     #declare _DRAW_ = true;
#end

// left turn (degrees)
#macro lt(d)
#ifdef(_INIT_)
     #declare _cD_ = _cD_ + d;
     #if(_cD_ > 360)
          #declare _cD_ = _cD_ - 360;
     #end
#end
#end

// right turn (degrees)
#macro rt(d)
#ifdef(_INIT_)
     #declare _cD_ = _cD_ - d;
     #if(_cD_ < -360)
          #declare _cD_ = _cD_ + 360;
     #end
#end
#end

// foreward (length)
#macro fd(l)
#ifdef(_INIT_)
     #local _pL_ = _cP_;
     #declare _cP_ = _cP_ + l*<cosd(_cD_), sind(_cD_), 0>;

     #if(_DRAW_)
          cylinder { _pL_, _cP_, 0.015625 pigment {Orange}
               finish { ambient 0.6 diffuse 0.3 } }
     #end
#end
#end

#macro home()



#debug concat("_cD_ = " str(_cD_,6,6) "\n")
#debug concat("_cP_ = <" str(_cP_.x,6,6) ", " str(_cP_.y,6,6) ", "
     str(_cP_.z,6,6)">\n")
#local rV = <0,0,0> - _cP_;
#local mag_rV = sqrt(pow(rV.x,2) + pow(rV.y,2));
#local rV = rV / mag_rV;
#debug concat("rV = <" str(rV.x,6,6) ", " str(rV.y,6,6) ", "
     str(rV.z,6,6)">\n")

#local cV = _cP_ + <cosd(_cD_),sind(_cD_),0>;
#local cV = cV / sqrt(pow(cV.x,2) + pow(cV.y,2));
#debug concat("cV = <" str(cV.x,6,6) ", " str(cV.y,6,6) ", "
     str(cV.z,6,6)">\n")

#local theta = degrees(acos(vdot(rV,cV)));
#debug concat(str(theta,6,6) "\n")
#debug concat(str(mag_rV,6,6) "\n")

#local hV = <0,0,0>;
/*
lt(theta)
fd(mag_rV)
lt(acos(vdot(rV,hV)))
*/
#end

#macro triline(len)

#if(len < 0.01)
     fd(len)
#else
     triline(len/3)
     lt(60)
     triline(len/3)
     rt(120)
     triline(len/3)
     lt(60)
     triline(len/3)
#end

#end

#macro triline2(len, epsilon)

#if(len < epsilon)
     fd(len)
#else
     lt(acos(5 * sqrt(7) / 14))
     triline2(len/sqrt(7), epsilon)
     rt(60)
     triline2(len/sqrt(7), epsilon)
     lt(60)
     triline2(len/sqrt(7), epsilon)
     rt(acos(5 * sqrt(7) / 14))
#end

#end

#macro koch(len)

pu()
lt(90)
fd(len*sind(30) - (len/3)*sind(30))
lt(90)
fd(len/2)
rt(180)
pd()
     #local a = 0;
     #while(a < 3)
          triline(len)
          rt(120)
     #local a = a + 1;
     #end
home()
#end

#macro gosper(len, epsilon)

     #local a = 0;
     #while(a < 6)
          triline2(len, epsilon)
          lt(60)
     #local a = a + 1;
     #end
#end

sphere { 0.0, 0.1 pigment { rgb 1 } }
init()
/*
pu()
lt(180)
fd(1.25)
rt(90)
fd(3.5)
rt(90)
pd()
*/
//triline2(2, 1)
gosper(2, 2/pow(sqrt(7),7))

//rt(30)
//fd(2)


Post a reply to this message


Attachments:
Download 'koch.png' (21 KB)

Preview of image 'koch.png'
koch.png


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.