|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
The following scene refuses to parse due to an error that POV describes as
"Too many nested symbol tables."
It appears to me to be a classic recursion case. I cannot think of any
reasonable way it could be done iteratively.
Those of you that understand what I'm trying to do, try to ignore anything
that looks odd, I translated the code from LOGO. That isn't easy.
/*
Persistence of Vision Ray-Tracer Scene Description File.
Name: Koch.pov
Vers: 3.6
Desc: A Koch Curve
Date: 033107
Auth: Anthony D. Baye
*/
#include "kolors.inc"
#include "textures.inc"
#include "metals.inc"
light_source { <2.5, 15.0, -7.5> rgb 1 }
camera {
orthographic
location 5.0*y
look_at 0.0
}
#macro Koch(Len, Lim, cP, cA)
#if(Len < Lim)
#local i = 0;
#while(i <= Len)
#local fd = <i*sin(radians(cA)), i*cos(radians(cA)), 0.0>;
sphere { cP, 0.00390625 translate fd texture { T_Silver_5A } }
#local i = i + 0.0078125;
#end
#end
Koch(
Len/3,
Lim,
<-Len/2, 0.0, 0.0>,
0.0
)
Koch(
Len/3,
Lim,
<(-Len/2)+(Len/3), 0.0, 0.0>,
cA+60
)
Koch(
Len/3,
Lim,
<(-Len/2)+(Len/3)+((Len/3)*cos(radians(cA)),
(Len/3)*sin(radians(cA)), 0.0>,
cA-120
)
Koch(
Len/3,
Lim,
<(-Len/2)+(2*Len/3), 0.0, 0.0>,
cA+60
)
#end
Koch(6.0, 1.0, 0.0, 0.0)
Like I said, I translated it from LOGO, so if it doesn't make the most
sense, it's because I'm still working on it, which is difficult when I
can't parse it.
There probably isn't a way to get it to work in this form with the current
version of POV, and I'm not as interested in iterative solutions, but If
anyone has a workaround... I'm all ears.
Regards,
ADB
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
The recursive calls should be in an else clause.
Otherwise they are being called even after the limit is reached and it
never ends.
Hence the overflow.
Anthony D. Baye wrote:
> The following scene refuses to parse due to an error that POV describes as
> "Too many nested symbol tables."
> It appears to me to be a classic recursion case. I cannot think of any
> reasonable way it could be done iteratively.
>
> Those of you that understand what I'm trying to do, try to ignore anything
> that looks odd, I translated the code from LOGO. That isn't easy.
>
> /*
> Persistence of Vision Ray-Tracer Scene Description File.
> Name: Koch.pov
> Vers: 3.6
> Desc: A Koch Curve
> Date: 033107
> Auth: Anthony D. Baye
> */
>
> #include "kolors.inc"
> #include "textures.inc"
> #include "metals.inc"
>
> light_source { <2.5, 15.0, -7.5> rgb 1 }
> camera {
> orthographic
> location 5.0*y
> look_at 0.0
> }
>
> #macro Koch(Len, Lim, cP, cA)
>
> #if(Len < Lim)
> #local i = 0;
> #while(i <= Len)
> #local fd = <i*sin(radians(cA)), i*cos(radians(cA)), 0.0>;
> sphere { cP, 0.00390625 translate fd texture { T_Silver_5A } }
> #local i = i + 0.0078125;
> #end
> #end
>
>
> Koch(
> Len/3,
> Lim,
> <-Len/2, 0.0, 0.0>,
> 0.0
> )
> Koch(
> Len/3,
> Lim,
> <(-Len/2)+(Len/3), 0.0, 0.0>,
> cA+60
> )
> Koch(
> Len/3,
> Lim,
> <(-Len/2)+(Len/3)+((Len/3)*cos(radians(cA)),
> (Len/3)*sin(radians(cA)), 0.0>,
> cA-120
> )
> Koch(
> Len/3,
> Lim,
> <(-Len/2)+(2*Len/3), 0.0, 0.0>,
> cA+60
> )
>
> #end
>
> Koch(6.0, 1.0, 0.0, 0.0)
>
> Like I said, I translated it from LOGO, so if it doesn't make the most
> sense, it's because I'm still working on it, which is difficult when I
> can't parse it.
>
> There probably isn't a way to get it to work in this form with the current
> version of POV, and I'm not as interested in iterative solutions, but If
> anyone has a workaround... I'm all ears.
>
> Regards,
>
> ADB
>
>
>
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Paul Fuller <pgf### [at] optusnetcomau> wrote:
> The recursive calls should be in an else clause.
>
> Otherwise they are being called even after the limit is reached and it
> never ends.
>
> Hence the overflow.
>
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.
Thanks for the input, Paul.
Regards,
ADB
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> 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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> 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.
The inner workings aren't that bad really, it just keeps track of the
turtle direction by rotating a unit vector when you turn. I threw in
tilt because POV is so 3D, vcross of the up and dir vectors is a
vector perpendicular... a right vector.
> 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.
Well, maybe, in general POV has trouble with heavy recursion, but
if you don't go crazy it'll work ok.
> I'm already thinking up uses for these macros though. You should submit
> them for inclusion in the libraries with version 4.
Fine by me, anything that can make things better.
#macro KochCurve(a, n)
#if (n = 1)
FD(a/3)
RT(60)
FD(a/3)
LT(120)
FD(a/3)
RT(60)
FD(a/3)
#else
KochCurve(a/3, n-1)
RT(60)
KochCurve(a/3, n-1)
LT(120)
KochCurve(a/3, n-1)
RT(60)
KochCurve(a/3, n-1)
#end
#end
#macro KochStar(a,n)
RT(30)
KochCurve(a,n)
LT(120)
KochCurve(a,n)
LT(120)
KochCurve(a,n)
LT(150)
#end
TiltUp(90)
PU()
BK(10)
PD()
#declare PenSize = 0.005;
KochStar(20,5)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|