|
![](/i/fill.gif) |
Doug Eichenberg wrote:
>Let's say I have an object "A" at the origin, and a known surface normal
><x,y,z>. I want to find the rotation vector <Rx,Ry,Rz> of the surface
>normal <x,y,z>, such that when I rotate "A":
>
>object{ A rotate<Rx,Ry,Rz> }
>
>it lies along the surface normal.
>
>I tried doing this as follows:
>
>object{ A rotate<atan2d(Norm.y,Norm.z), atan2d(Norm.x,Norm.z),
>atan2d(Norm.x,Norm.y)>
>
>but I seem to be getting strange results.
>
>Anyone have code they used for doing this? Or know how in general?
>Thanks for the help.
Without checking your trigonometry, I can see you have fallen prey to one of
the most popular - and my first - error of trigonometric transformation.
Try 'object { A rotate < degrees(atan2(Norm.y,Norm.z), ... etc.) > }'
The problem is the inverse trig functions return radians, and rotate
expects degrees. Forward trig functions also -take- radians, so, pretty much
any time you want to use the trig functions you have to constantly use the
radians() and degrees() functions as well.
Good luck!
--Chris
Post a reply to this message
|
![](/i/fill.gif) |