POV-Ray : Newsgroups : povray.newusers : rotate object does not seem to work Server Time
25 Nov 2024 11:26:10 EST (-0500)
  rotate object does not seem to work (Message 1 to 4 of 4)  
From: Edee
Subject: rotate object does not seem to work
Date: 19 Nov 2005 19:15:01
Message: <web.437fbed72993e19e8bbafa7b0@news.povray.org>
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


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: rotate object does not seem to work
Date: 19 Nov 2005 20:25:00
Message: <web.437fcfe7a413c3ef272622110@news.povray.org>
"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

From: Mike Williams
Subject: Re: rotate object does not seem to work
Date: 19 Nov 2005 20:36:27
Message: <MKyA9FALM9fDFwe9@econym.demon.co.uk>
Wasn't it Edee who 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
> ...
>        rotate <0,90,0>

You're rotating each beam by the same amount. To rotate each beam
differently you need to use something like this

        rotate <0,90-i*rrate*180/pi,0>

Note that "rotate" uses degrees, but rrate is in radians, hence the
*180/pi.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Edee
Subject: Re: rotate object does not seem to work
Date: 19 Nov 2005 21:35:01
Message: <web.437fe0aaa413c3ef8bbafa7b0@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:
> Wasn't it Edee who 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
> > ...
> >        rotate <0,90,0>
>
> You're rotating each beam by the same amount. To rotate each beam
> differently you need to use something like this
>
>         rotate <0,90-i*rrate*180/pi,0>
>
> Note that "rotate" uses degrees, but rrate is in radians, hence the
> *180/pi.
>
> --
> Mike Williams
> Gentleman of Leisure


My confusion arose out of the radians for trig functions, and rotations
being in degrees and needed a negative value to have the radial effect
desired of a spiral stair case.  The snippet also did not include the
variable being used.  I also plan to use upper case variable name for final
version.
The version that seems to work for me follows, thank you all for your help.

      #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 -a*y
        translate <R*cos(a*pi/180), h, R*sin(a*pi/180) >
        //translate y*h
         }
        #local a = a + da;
        #local i = i + 1;
        #local h = h + dh;

      #end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.