POV-Ray : Newsgroups : povray.newusers : rotating objects in a circle Server Time
29 Jul 2024 10:28:27 EDT (-0400)
  rotating objects in a circle (Message 1 to 3 of 3)  
From: wizkidguy
Subject: rotating objects in a circle
Date: 31 Mar 2006 20:45:00
Message: <web.442dda34c4964c69bbb7f5d50@news.povray.org>
I am trying to rotate a group of objects in a circle. how can i do this? i
am using a while loop and i cannot figure out to make them move in a
circle.


Post a reply to this message

From: Larry Hudson
Subject: Re: rotating objects in a circle
Date: 31 Mar 2006 23:40:00
Message: <442e0420@news.povray.org>
wizkidguy wrote:
> I am trying to rotate a group of objects in a circle. how can i do this? i
> am using a while loop and i cannot figure out to make them move in a
> circle.
> 
Thats what the Povray rotate is for.  But remember, all rotations, (and 
scalings) are relative to the coordinate axes.  This means you have to 
create your set of objects centered at the origin (or translate them 
there) to perform the rotation, then, if necessary, translate them to 
their final location.  This is easiest if you make your set of objects a 
union so you can rotate and translate them as a unit.

As a short example, there was an animated image that was rather commonly 
available many years ago.  Here is my attempt at recreating that image. 
  (The original used a 2x2 checkerboard, mine is 4x4, and I don't 
remember what the original background was like -- I made mine a simple 
sky-sphere.)  Incidentally, the original image was said to be made with 
Povray -- I think that is where I first learned about it.  (Probably 
still at version 1 at that time.)    :-)


//	balls.pov -- Attempting to reproduce the rotating ball
//				 image from years ago

#include "colors.inc"
#include "skies.inc"

camera
{
	location <3, 5, -15>
	look_at <0, -2, 0>
	angle 40
}

light_source { <-5, 20, -30> White }
light_source { <10, 50, -20> Gray50 }

sky_sphere { S_Cloud3 }

box
{
	<-5, -2.5, -5>, <5, -2, 5>
	pigment { checker Red White scale 2.5 }
}

#declare Ball = sphere
{
	0, .8
	pigment { Black }
	finish { reflection 1 phong .8 }
}

//	Create the circle of 8 balls
#declare Circle = union
{
	#local Angle = 0;
	#while (Angle < 360)
		object
		{
			Ball
			translate <4, 0, 0>
			rotate <0, Angle, 0>
		}
		#local Angle = Angle + 45;
	#end
}

//	Animate (rotate) the circle
object
{
	Circle
	rotate <0, clock * 45, 0>
}


Post a reply to this message

From: wizkidguy
Subject: Re: rotating objects in a circle
Date: 1 Apr 2006 15:55:00
Message: <web.442ee8a0379a591fbbb7f5d50@news.povray.org>
Larry Hudson <org### [at] yahoocom> wrote:
> wizkidguy wrote:
> > I am trying to rotate a group of objects in a circle. how can i do this? i
> > am using a while loop and i cannot figure out to make them move in a
> > circle.
> >
> Thats what the Povray rotate is for.  But remember, all rotations, (and
> scalings) are relative to the coordinate axes.  This means you have to
> create your set of objects centered at the origin (or translate them
> there) to perform the rotation, then, if necessary, translate them to
> their final location.  This is easiest if you make your set of objects a
> union so you can rotate and translate them as a unit.
>
> As a short example, there was an animated image that was rather commonly
> available many years ago.  Here is my attempt at recreating that image.
>   (The original used a 2x2 checkerboard, mine is 4x4, and I don't
> remember what the original background was like -- I made mine a simple
> sky-sphere.)  Incidentally, the original image was said to be made with
> Povray -- I think that is where I first learned about it.  (Probably
> still at version 1 at that time.)    :-)
>
>
> // balls.pov -- Attempting to reproduce the rotating ball
> //     image from years ago
>
> #include "colors.inc"
> #include "skies.inc"
>
> camera
> {
>  location <3, 5, -15>
>  look_at <0, -2, 0>
>  angle 40
> }
>
> light_source { <-5, 20, -30> White }
> light_source { <10, 50, -20> Gray50 }
>
> sky_sphere { S_Cloud3 }
>
> box
> {
>  <-5, -2.5, -5>, <5, -2, 5>
>  pigment { checker Red White scale 2.5 }
> }
>
> #declare Ball = sphere
> {
>  0, .8
>  pigment { Black }
>  finish { reflection 1 phong .8 }
> }
>
> // Create the circle of 8 balls
> #declare Circle = union
> {
>  #local Angle = 0;
>  #while (Angle < 360)
>   object
>   {
>    Ball
>    translate <4, 0, 0>
>    rotate <0, Angle, 0>
>   }
>   #local Angle = Angle + 45;
>  #end
> }
>
> // Animate (rotate) the circle
> object
> {
>  Circle
>  rotate <0, clock * 45, 0>
> }

Thank you very much. that is exactly the idea i needed!!


Post a reply to this message

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