|
![](/i/fill.gif) |
> 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
|
![](/i/fill.gif) |