POV-Ray : Newsgroups : povray.text.tutorials : Using the sin fuction to move the camera : Re: Using the sin fuction to move the camera Server Time
1 May 2024 09:23:20 EDT (-0400)
  Re: Using the sin fuction to move the camera  
From: Ken
Date: 26 Oct 1999 19:42:46
Message: <38163BDC.E9581021@pacbell.net>
TigerHawk wrote:
> 
> I have been  wondering lately how one would go about moving a camera in
> a well defined path. I know there are include files to help you with
> this (I already have one that does work quite well). However, the
> problem with include files is that I can't seem to get the effect I want
> in a scene, and the include files are much harder to use than a simple
> formula.
> 
> So I have been wondering what formula one might use to move the camera
> along a sin path. For example, starting at the origin and moving forware
> as time passes, with each imcrement of the frame, computing the x,y
> value of the location on the sine.
> 
> If that makes any sense :) I know I can do it using radians in terms of
> PI, but that does not help put what I need to do to practice (ie 60
> frames would equal 1 frequency of the sine wave).
> 
> Any ideas?

This should not be too difficult to do with a simple while loop incremented
by the clock, the correct formula, and use the translate or location function
to control the position of the camera.

Perhaps something like this might apply but is only partialy tested.
The frequency will depend on the number of frames and the amplitude
can be adjusted by changing the sin multiplier and the pi divisor.
Someone is sure to point out some flaws in my example and offer better
options but here it is for what it is worth.

Example:

#declare Frames = 20; // make this equal to the number of frames of anim.

#declare i=0;
 #while ( i < Frames*clock)
   camera { location<-Frames/2,0,-20> look_at 0 translate<i,10*sin(i*pi/10),-20>}
 #declare i = i + 1;
#end

light_source{<0,0,-300>rgb 1}
light_source{<0,300,-30>rgb 1}

sphere{<0,0,0>,5 pigment {rgb 1}}

plane{y,0 pigment{checker color rgb .6 color rgb .8 scale 10}}

Get ready for a wild ride :~)
 
> Ken: Thanks for the include file information - I'll be sure to look at
> it as it may make my life a while lot easier :) Especially if leaves
> already exist on the tree...

Glad to help.

-- 
Ken Tyler -  1100+ Povray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

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