POV-Ray : Newsgroups : povray.text.tutorials : Using the sin fuction to move the camera Server Time
18 Apr 2024 19:44:58 EDT (-0400)
  Using the sin fuction to move the camera (Message 1 to 5 of 5)  
From: TigerHawk
Subject: Using the sin fuction to move the camera
Date: 26 Oct 1999 18:49:52
Message: <38163178.8CCDE760@stic.net>
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?

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...


Tim Soderstrom
TigerHawk
Tig### [at] SticNet


Post a reply to this message

From: Chris Huff
Subject: Re: Using the sin fuction to move the camera
Date: 26 Oct 1999 19:17:59
Message: <38163737.390A40E2@yahoo.com>
#declare frequency = 3;
#declare amplitude = 1;
#declare distance = 10;
#declare height = 1;

camera {
    location < sin(radians(clock*360*frequency)), height, clock*distance
- distance>
...other camera stuff...
}

Note that if you want the point the camera looks at to move, you would
have to modify it too. Actually, it would be better to use translate in
that case.
camera {
    location blahblah
    look_at blahblah
...other camera stuff...
    translate < sin(radians(clock*360*frequency)), height,
clock*distance - distance>
}


Post a reply to this message

From: Ken
Subject: Re: Using the sin fuction to move the camera
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

From: Nieminen Juha
Subject: Re: Using the sin fuction to move the camera
Date: 27 Oct 1999 05:38:43
Message: <3816c823@news.povray.org>
People have suggested some complicated solutions. Actually the solution
is pretty simple:

camera
{ location <PathXLength*clock, Amplitude*sin(radians(FinalAngle*clock)), 0>
}

where FinalAngle is for example 360.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: TigerHawk
Subject: Re: Using the sin fuction to move the camera
Date: 5 Nov 1999 19:56:54
Message: <38237D01.FB52F3EA@stic.net>
Thanks a bunch for the help - it still looks rather foreign to me, but it
looks fairly easy to work with. I am assuming then it'd be easy to move the
camera in a circle as well?  (one wouldn't use a sin function for that,
though, heh).

Happy tracing (to all who responded),
Tim Soderstrom
TigerHawk

Chris Huff wrote:

> #declare frequency = 3;
> #declare amplitude = 1;
> #declare distance = 10;
> #declare height = 1;
>
> camera {
>     location < sin(radians(clock*360*frequency)), height, clock*distance
> - distance>
> ...other camera stuff...
> }
>
> Note that if you want the point the camera looks at to move, you would
> have to modify it too. Actually, it would be better to use translate in
> that case.
> camera {
>     location blahblah
>     look_at blahblah
> ...other camera stuff...
>     translate < sin(radians(clock*360*frequency)), height,
> clock*distance - distance>
> }


Post a reply to this message

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