POV-Ray : Newsgroups : povray.general : Math Question : Re: Math Question Server Time
10 Aug 2024 15:16:33 EDT (-0400)
  Re: Math Question  
From: David Vincent-Jones
Date: 3 Dec 1999 00:20:50
Message: <38475332@news.povray.org>
I tried to use this approach but unfortunately I need a more generalized
solution.
All I need.. is the angle (direction) between 2 vector locations..
but I need to ensure that it works in any and all quadrants.
My objects can always be rotated at origin prior to any move.
Surely there must be an easy solution sitting somewhere.
mr.art <mr.### [at] gcinet> wrote in message news:38469CB9.D481A3FA@gci.net...
> I had a simular problem with eyes and looking
> at one spot. this is a solution.
> given P1,P2 are location vectors
> angle functions return radian values
> degrees() accepts radians and returns degrees
>
> Use the function vnormalize(P2-P1) to return a vector of
> unit lingth that points from P1 to P2.
> Use -degrees(asin(z componant)) and  degrees(asin(y componant))
> to return the amount of degrees that the object must be
> rotated while at P2 to face P1.
> This assumes that the object is "facing" in the -x direction.
>
> I have used a macro to keep the intent of the code clear.
> I hope this helps. It gave me good results in making a
> mannequin look at the camera.
>
> #macro v_lookat(P1,P2)
> #local Norm=(vnormalize(P2-P1));
> <0,-degrees(asin(Norm.z)),degrees(asin(Norm.y))>
> #end
>
> #declare CameraPosition <-35,67,-16>;
> #declare PicturePosition <2,-1,3>;
> object {
> Picture
> rotate v_lookat( CameraPosition , PicturePosition )
> translate PicturePosition
> }


Post a reply to this message

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