|
|
I was going to wait to debut this until I'd gotten the finished product done,
but I could use a second (or third/fourth/etc..) set of eyes on the problem.
The problem is an aperiodic tiling with sixfold symmetry, and it almost works,
but suddenly fails at anything more than 3 levels deep.
the following snippet is from geometry.pov, and I believe this is where the
problem is:
push(array[3] { t1[1] + baseVec*baseLen/3, t1[0], t1[1] })
push(array[3] { t1[0],
t1[1] + baseVec*baseLen/3,
t1[2] - baseVec*baseLen/3 })
push(array[3] { t1[1] + baseVec*2*baseLen/3, t1[0], t1[2] })
if I comment out the second push operation, the ugliness goes away, but no more
equilateral triangles are introduced and the pattern has large (if interesting)
gaps in it.
I would appreciate it if anyone could help me with this.
sorry about the messy code. The image shows the pattern at 3 levels deep.
Regards,
A.D.B.
// BEGIN stack.inc
#include "math.inc"
#include "arrays.inc"
#version 3.7;
//#declare STACKDEBUG = 0;
#declare maxStack = 50;
#declare stackPointer = 0;
#declare stackSize = 0;
#declare STACK = array[maxStack]
#macro push(item)
#if(stackSize > 0)
#declare stackPointer = stackPointer + 1; // First, increment
stackPointer.
// if the stack is full, double the capacity.
// like an array-based hash, except we don't need to worry about
collisions.
#if(stackPointer = maxStack)
#declare maxStack = maxStack * 2;
Resize_Array(STACK, maxStack)
#end
#end
#declare STACK[stackPointer] = item;
#declare stackSize = stackSize + 1;
#end
#macro pop(receiver)
#if(stackSize > 0)
#ifdef(STACKDEBUG)
#debug concat("stackPointer: ", str(stackPointer, 1, 0), "\n")
#debug concat("maxStack:", str(maxStack, 1, 0), "\n")
#debug concat("stackSize: ", str(stackSize, 1, 0), "\n")
#end
#local temp = STACK[stackPointer]; // grab the top item
#if(stackPointer > 0)
#declare stackPointer = stackPointer - 1; // decrement
stackPointer
#end
// if the stack is less than a quarter full, but maxStack is greater
than 50,
// halve the size.
#if(maxStack > 50 & stackPointer < maxStack * 0.25)
#declare maxStack = maxStack / 2;
Resize_Array(STACK, maxStack)
#end
#declare stackSize = stackSize - 1;
#declare receiver = temp;
#end
#end
#macro top(receiver)
#if(stackSize != 0)
#declare receiver = STACK[stackPointer];
#end
#end
#macro isEmpty()
#if(stackSize = 0)
#local return = true;
#else
#local return = false;
#end
return
#end
// END stack.inc
// BEGIN geometry.pov
#version 3.7;
#include "math.inc"
#include "colors.inc"
#include "stack.inc"
global_settings {
assumed_gamma 1.0
}
light_source { <0.0, 20.0, 0.0> rgb 1 }
camera {
perspective
location <0.0, 20.0, 0.0>
up y
right x*(image_width/image_height)
look_at 0
}
#default { pigment { rgb <0.08, 0.375, 0.75> } }
prism {
linear_spline
-0.25, 0.0, 7
#for(a,0,360,60)
10.0*<cosd(a), sind(a)>
#end
}
#declare triangles = array[6]
//#for(T,0,360,60)
// cylinder { 3.0*<cosd(T), 0.0, sind(T)> 3.0*<cosd(T+60), 0.0, sind(T+60)>
0.03125 pigment { Orange } }
// cylinder { 3.0*<cosd(T), 0.0, sind(T)> 0.0 0.03125 pigment { Orange } }
//#end
#local T = 0;
#while(T < 360)
push(array[3] { <0.0, 0.0, 0.0> , 10.0*<cosd(T), 0.0, sind(T)>,
10.0*<cosd(T+60), 0.0, sind(T+60)> })
// #declare triangles[ceil(T/72)] = array[3] { <0.0, 0.0, 0.0> ,
3.0*<cosd(T), 0.0, sind(T)>, 3.0*<cosd(T+60), 0.0, sind(T+60)> }
#local T = T + 60;
#end
#declare t1 = <0,0,0>;
//#for(Z,0,5,1)
//#declare t1 = triangles[Z]
//pop(t1)
#macro subdivide(T1)
#declare v1 = T1[1] - T1[0];
#declare v2 = T1[2] - T1[0];
#declare T = acos(vdot(vnormalize(v1),vnormalize(v2)));
#declare xOff = acos(vdot(vnormalize(v1),<1,0,0>));
#declare sideLen = vlength(v1);
#declare bVec = sideLen*<cos(xOff + T/2), 0, sin(xOff + T/2)>;
#declare centroid = <(T1[0].x + v1.x + v2.x)/3,
(T1[0].y + v1.y + v2.y)/3,
(T1[0].z + v1.z + v2.z)/3>;
#local Area = abs(
(
T1[0].x*(T1[1].z - T1[2].z) +
T1[1].x*(T1[2].z - T1[0].z) +
T1[2].x*(T1[0].z - T1[1].z)
) / 2
);
//#declare centroid2 = t1[0] + vnormalize(bVec)*(sideLen/(2*cos(T/2)));
#debug concat ("T: ", str(degrees(T), 1, 6), "\n")
#debug concat ("xOff: ", str(xOff, 1, 6), "\n")
//#debug concat ("Area: ", str(Area, 1, 12), "\n")
//cos(Alpha) = B/C ==> B = C*cos(Alpha) ==> C = B/cos(Alpha)
//sphere { t1[0] + bVec/2, 0.03125 pigment { Orange } }
//#if(Area > 3)
#if(degrees(T) = 60)
#debug "Type: 1\n"
push(array[3] { centroid , T1[1], T1[0] })
push(array[3] { centroid , T1[2], T1[0] })
push(array[3] { centroid , T1[1], T1[2] })
#else
#local baseVec = vnormalize(T1[2] - T1[1]);
#local baseLen = vlength(T1[2] - T1[1]);
#debug "Type: 2\n"
#debug concat("baseVec: " vstr(3, t1[2]-t1[1], ", ", 1, 12) "\n")
#debug concat("baseLen: " str(baseLen, 1, 12) "\n")
// !!!!!!!!!! I believe the problem is here !!!!!!!!!!!!
push(array[3] { t1[1] + baseVec*baseLen/3, t1[0], t1[1] })
push(array[3] { t1[0], t1[1] + baseVec*baseLen/3, t1[2] -
baseVec*baseLen/3 })
push(array[3] { t1[1] + baseVec*2*baseLen/3, t1[0], t1[2] })
#end
#end
//pop(t1)
//subdivide(t1)
//pop(t1)
//subdivide(t1)
//pop(t1)
//subdivide(t1)
//#else
#while(!isEmpty())
//#for(p,0,8,1) // for investigating the generation stepwise.
pop(t1)
#local Area =
abs(
(
t1[0].x*(t1[1].z - t1[2].z) +
t1[1].x*(t1[2].z - t1[0].z) +
t1[2].x*(t1[0].z - t1[1].z)
) / 2
);
#debug concat ("Area: ", str(Area, 1, 12), "\n")
#if(Area > 5)
subdivide(t1)
#else
// #debug concat("t1[1]: ", vstr(3, <t1[1].x, t1[1].y, t1[1].z>, ", ", 1, 6),
"\n")
// #debug concat("t1[2]: ", vstr(3, <t1[2].x, t1[2].y, t1[2].z>, ", ", 1, 6),
"\n")
sphere { t1[0] 0.0625 pigment { Blue } }
cylinder { t1[0], t1[1], 0.015625 pigment { Red } }
cylinder { t1[1], t1[2], 0.015625 pigment { Yellow } }
cylinder { t1[2], t1[0], 0.015625 pigment { Red } }
#end
#end
// End geometry.pov
Post a reply to this message
Attachments:
Download 'geometry.png' (138 KB)
Preview of image 'geometry.png'
|
|