|
|
"Edee" <rah### [at] yahoocom> wrote:
> In the snippet below, the object rotate does not rotate when a variable
> value but works with a fixed value. It appears to be always set to zero
> (no rotaion0 when a variable is used. The goal was to create a spiral
> series of I-beams. Can anyone help me with what I am doing wrong?
> thanks
> #declare i = 0;
> #declare h = 0; //elevation
> #declare R = 5; //outer radius
> #declare a = 0;
> #declare da = 360/40;
> #declare bpi = 40; //beams per pi
> #declare rrate = 5*2*pi/360; //ramprate
> #declare bspan = 2*pi*R/40;
> #declare dh = bspan*tan(rrate);
> #while (i<40)
> object { I_beam
> texture { Steel_Beam }
> rotate <0,90,0>
> translate <R*cos(a), h, R*sin(a) >
> }
> #local a = a + da;
> #local i = i + 1;
> #local h = h + dh;
>
> #end
It is somewhat unclear to me what you are trying to achieve.
(But at least I can assure you that rotations do indeed also work with
variables.)
Please have a look at the code below. I don't know if it does what you want,
but I have tried to make the code better and more understandable for
others.
If you need more help, then please post a more complete example that
illustrates your problem. You should make it so that we don't have to add a
lot of lines with camera, light sources, shapes, textures etc in order to
make a test render.
#declare NrOfBeams = 40;
#declare Radius = 5;
// I don't see what you are trying to do within the 3 lines below.
#declare Bspan = Radius*2*pi/NrOfBeams;
#declare RampRate = radians(5);
#declare dHeight = Bspan*tan(RampRate);
#declare dAngle = 360/NrOfBeams;
#declare Angle = 0;
#declare Height = 0;
#declare I = 0;
#while (I < NrOfBeams)
#declare Height = Height + I*dHeight;
#declare Angle = Angle + I*dAngle;
object {
I_beam
translate <Radius, Height, 0>
rotate (90 + Angle)*y
pigment { color Red }
}
#declare I = I + 1;
#end // while
You should avoid using variable names with only lower case letters.
I recommend that you look up the radians() and degrees() keywords in the
manual and also check that you know which keywords expect radians and which
expect degrees as arguments.
--
Tor Olav
http://subcube.com
Post a reply to this message
|
|