POV-Ray : Newsgroups : povray.general : Recursion re...uh..iterated? : Re: Recursion re...uh..iterated? Server Time
31 Jul 2024 10:17:27 EDT (-0400)
  Re: Recursion re...uh..iterated?  
From: Anthony D  Baye
Date: 3 Apr 2007 18:10:01
Message: <web.4612cf8993745152ddcb0b920@news.povray.org>
Uh, gee.  Thanks, Tim, but... I didn't get you anything...

Seriously, though, It's great, but it's going to take me a while to figure
out what you did, I'm not familiar with some of the functions you used.

But what I'm working on may not be compatible with a logo approach.  I'm
trying to generate fractal snowflakes and ice crystals.  It's more a
learning experience than anything else.

I'm already thinking up uses for these macros though.  You should submit
them for inclusion in the libraries with version 4.

Regards,

ADB

"Look around you.  Your kingdom is blessed beyond any land's deserving
because they passed across it in freedom.  And as for your heart, and all
the things you said and didn't say; She will remember them when Men are
fairy tales in books written by rabbits.  Think on that, and be still."

"Tim Attwood" <tim### [at] comcastnet> wrote:
> > Thanks, I really should have seen that.  The problem now is passing the
> > correct values for position to the recursive calls.  The thing about LOGO
> > is that it remembers the position and direction of the turtle at all
> > times,
> > it will continue moving on a set vector unless you tell it otherwise.
> > POV,
> > on the other hand, has to be told where to go and what to do once it gets
> > there.
>
>
> // Macros for treating POV-Ray like LOGO --  by Tim Attwood 4/2/2007
> #declare PenSize = 0.025;
> #declare PenColor = Yellow;
> #declare PenStep = 0.1;
> #declare PenState = on;
> #declare PenDir = <0,0,1>;
> #declare PenUp = <0,1,0>;
> #declare PenLoc = <0,0,0>;
> #macro Turtle() cone{PenLoc,PenSize*2,PenLoc+PenDir*PenStep*4,0
>    pigment{color PenColor}} #end
> #macro PU() #declare PenState = off; #end
> #macro PD() #declare PenState = on; #end
> #macro FD(a)
>    #local b = PenLoc+PenDir*PenStep*a;
>    #if (PenState = on)
>       cylinder{PenLoc, b, PenSize pigment{color PenColor} }
>       sphere{b,PenSize pigment{color PenColor}}
>    #end
>    #declare PenLoc = b;
> #end
> #macro BK(a)
>    #local b = PenLoc-PenDir*PenStep*a;
>    #if (PenState = on)
>       cylinder{PenLoc,b,PenSize pigment{color PenColor}}
>       sphere{b pigment{color PenColor}}
>    #end
>    #declare PenLoc = b;
> #end
> #macro LT(a) #declare PenDir = vaxis_rotate(PenDir,PenUp,-a); #end
> #macro RT(a) #declare PenDir = vaxis_rotate(PenDir,PenUp,a); #end
> #macro TiltUp(a)
>    #local r = vnormalize(vcross(PenDir,PenUp));
>    #declare PenDir = vaxis_rotate(PenDir,r,a);
>    #declare PenUp = vaxis_rotate(PenUp,r,a);
> #end
> #macro TiltDown(a)
>    #local r = vnormalize(vcross(PenDir,PenUp));
>    #declare PenDir = vaxis_rotate(PenDir,r,-a);
>    #declare PenUp = vaxis_rotate(PenUp,r,-a);
> #end
>
> // example
> #macro Tree(a, stopat)
>    #if (a > stopat)
>       RT(30)
>       FD(a)
>       Tree( a/2, stopat)
>       PU()
>       BK(a)
>       LT(60)
>       PD()
>       FD(a)
>       Tree( a/2, stopat)
>       PU()
>       BK(a)
>       RT(30)
>       PD()
>    #end
> #end
>
> PU()
> TiltUp(90)
> BK(10)
> PD()
> #declare PenColor = Brown;
> FD(5)
> #declare PenColor = Green;
> Tree(10,0.5)
> #declare PenColor = Yellow;
> FD(4)
> Turtle()


Post a reply to this message

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