POV-Ray : Newsgroups : povray.advanced-users : Simple one : Re: Simple one Server Time
28 Jul 2024 10:31:37 EDT (-0400)
  Re: Simple one  
From: Orchid XP v2
Date: 11 Mar 2006 16:10:09
Message: <44133cb1$1@news.povray.org>
> OK, this is going to take somebody about 3 seconds to answer I would 
> think...
> 
> I have an object who's surface normal is +Y. I need to rotate it in such 
> a way that its surface normal becomes equal to a user-supplied vector. 
> How do I figure out the necessary angles?

By a process of elimination, I eventually managed to puzzle out 
something that works...

#declare O = object {with surface normal = +y};
#declare K = <what you want the surface normal to become>;

object
{
   O

   rotate x*atan2(K.y, K.z)
   rotate z*atan2(K.x, K.y)
}


Oh, except that that won't *really* work, because it seems atan2() spits 
out a fatal parse error if the first argument is 0. (!!) Thanks. That's 
really helpful to me. [sigh] So what you *really* have to do is this:

object
{
   O

   #if (K.y != 0) rotate x*atan2(K.y, K.z) #end
   #if (K.x != 0) rotate z*atan2(K.x, K.y) #end
}

...just in case anybody else wanted to know.


Post a reply to this message

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