|
![](/i/fill.gif) |
OK, this is weird...
This macro seems to exhibit a strange bug: when the random number seed is set to 1322
or 1342 (as far as I've discovered) the 3rd segment of the "worm" gets misaligned. The
misalignment grows with the total number of segments. I can't find any errors in my
code...
Could sb. try it out and tell me if I'm just being stupid or is this a genuine bug?
Thanx
Margus
//BEGIN SCENE
camera {orthographic
location <0,10,2>
up 10*.75*y
right 10*x
look_at z*2}
light_source {<20,60,-10> color 1}
#include "colors.inc"
//Generates random "Worm"
//LenStart length of first segment
//LenEnd length of last segment
//NumSegm number of segments
//ExpL segment length falloff (1-linear; 2-squared etc)
//RadStart worm start radius
//RadEnd worm end radius
//ExpW worm radius falloff
//Random randomness in X,Y and Z directions (vector expression)
//Seed random number seed
#macro Interpolate(GC,GS,GE,PS,PE,EXP)
(PS+(PE-PS)*pow((GC-GS)/(GE-GS),EXP))
#end
#declare PointStart = <0,0,0>;
#macro Worm(LenStart, LenEnd, NumSegm, ExpL, RadStart, RadEnd, ExpW, Random, Seed)
#declare CurSegm = 0;
#declare PointEnd = <0,0,LenStart>;
#declare RadConst = RadStart;
#declare RadAspect = RadEnd/RadStart;
#declare LenAspect = LenEnd/LenStart;
#declare MaxTwist = 90;
#declare R1 = seed(Seed);
union {
#while (CurSegm < NumSegm)
#declare
RadEnd=RadConst*Interpolate(CurSegm+1,0,NumSegm,1,RadAspect,ExpW);
cone {PointStart, RadStart, PointEnd, RadEnd}
#declare
PointNew=PointEnd+vrotate(LenStart*vnormalize(PointEnd-PointStart)*Interpolate(CurSegm+1,0,NumSegm,1,LenAspect,ExpL)*1.00001,<0+Random.x*(MaxTwist*rand(R1)-MaxTwist/2),0+Random.y*(MaxTwist*rand(R1)-MaxTwist/2),0+Random.z*(MaxTwist*rand(R1)-MaxTwist/2)>);
#declare PointStart=PointEnd;
#declare PointEnd=PointNew;
#declare RadStart=RadEnd;
#declare CurSegm=CurSegm+1;
#end}
#end
object {Worm(.3,0,50,2,.3,0,2,<0,.1,0>,1342) pigment{Red} finish{ambient .3}}
Post a reply to this message
|
![](/i/fill.gif) |