POV-Ray : Newsgroups : povray.tools.general : sin cos delta : Re: sin cos delta Server Time: 6 Sep 2008 04:29:08 GMT
  Re: sin cos delta  
From: Roman Reiner
Date: 29 May 2007 13:35:01
You'd probably need to use atan(dy/dx). however the usage of atan is a
little problematic since dx is not necessarily unequal zero and it's
difficult to get exact angles since e.g. atan(1) could be both 45° or 225°
(which is the opposite direction).

I recommend using one vector for the direction and speed (with the speed
being the length of the direction vector) and one for the location. So
instead of

x = x + speed * sin(direction * 2*pi)
y = y + speed * cos(direction * 2*pi)

you'd have

Position = Position+Direction ( with Direction = vnormalize(<dx,dy>)*Speed )

if you need to access the former x and y components use

x=Position.x
y=Position.y

Hope that helps!
Regards Roman


Post a reply to this message

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