POV-Ray : Newsgroups : povray.newusers : problem using rotate in a while loop : Re: problem using rotate in a while loop Server Time
31 Jul 2024 02:32:18 EDT (-0400)
  Re: problem using rotate in a while loop  
From: Tor Olav Kristensen
Date: 10 Feb 2003 17:30:11
Message: <web.3e4827d1367de2c2b417814a0@news.povray.org>
Suso Banderas wrote:
>I'm trying to make a scene where several boxes form a circle and
>are tangent to the circle.  in other words, each box would be
>rotated a certain amount as they are placed around the circle.
>I tried doing this with a while loop and a couple of variables.
>I can get the translation to work, but the rotate doesn't work.
>What could I be doing wrong?  By the way, I already tried making
>the box a declared object that is defined outside the while loop.
>Thanks for your help.
>
>#include "colors.inc"
>
>light_source { <-10, 20, 0> color White }
>light_source { <0, 50, 0> color White }
>
>
>plane {
>    y, -1
>    pigment { checker color Black color White scale 5 rotate y*45 }
>}
>
>camera {
>    location <0, 20, 0>
>    look_at <0, 0, 0>
>}
>
>#declare rad = 10;     // radius of circle
>#declare objects = 9;  // number of objects in circle
>#declare position = 0;  // starting position
>#declare increment = 2*pi / objects;  // increment between objects
>#declare degree = 180/pi;  // Radian to degree conversion
>
>#declare thisobject = box {
>    <-1,-1,-1>
>    <1,1,1>
>    pigment { color Green }
>    rotate <0,increment*degree,0>
>}
>
>#while (position < 2*pi)
>    box {
>        <-1,-1,-1>
>        <1,1,1>
>        pigment { color Green }
>        rotate <0,increment*degree,0>  // rotate the box so that it is tangent.
>        translate <cos(position)*rad, 0, sin(position)*rad>
>    }
>    #declare position = position + increment;
>#end
>

You can just change this line:
rotate <0,increment*degree,0>

- to this:
rotate <0,-position*degree,0>


Tor Olav


Post a reply to this message

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