|
|
> I've tried that. I get "too many nested symbol tables"
Odd, I wrote it like that to test out the math I posted yesterday and it
worked fine. The complete code is copy & pasted below (I just tried it
with 10 recursion depth and it's fine - higher maybe work too but I ran
out of patience waiting for it to parse).
The non-recursive version could just have an array of points (start with
just two). Each time you run the macro it would create a new array, and
for each pair of points in the input array create 3 new points in the
output array. You'd then use that output array as the input for the next
call...
------
#version 3.7;
global_settings { assumed_gamma 1.8 }
#include "colors.inc"
#include "math.inc"
light_source { <0.0, 0.0, -10.0> rgb 1 }
camera {
perspective
location <0.0, 0.0, -10.0>
up y
right x*(image_width/image_height)
look_at <0.0, 0.0, 0.0>
}
#default {
pigment { Orange }
finish { ambient 0 diffuse 0.7 }
}
#macro vec2rot(V, A)
#local _X_ = V.u*cos(A) - V.v*sin(A);
#local _Y_ = V.u*sin(A) + V.v*cos(A);
#local RESULT = <_X_,_Y_>;
RESULT
#end
#macro gosper_axiom(p0, p1,N)
#if(N>=0)
cylinder { p0, p1 0.0078125 }
#local V = p1 - p0;
#local vT = vnormalize(V);
#local len = vlength(V);
#local np1 = p0 + len/sqrt(7)*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));
#local np2 = p1 - len/sqrt(7)*vec2rot( vT,asin(sqrt(3)/(2*sqrt(7))));
gosper_axiom(p0,np1,N-1)
gosper_axiom(np1,np2,N-1)
gosper_axiom(np2,p1,N-1)
#end
#end
#declare TH = degrees(asin(sqrt(3)/(2*sqrt(7))));
#declare L = 6.0/sqrt(7);
#debug concat("L: " str(L,0,6) "\n")
#declare pA = <-3,0>;
#declare pB = <3,0>;
gosper_axiom(pA,pB,10)
Post a reply to this message
|
|