POV-Ray : Newsgroups : povray.advanced-users : rotating parallel to surface normal : Re: rotating parallel to surface normal Server Time
28 Jul 2024 22:27:13 EDT (-0400)
  Re: rotating parallel to surface normal  
From: Chris Amshey
Date: 27 Jul 2003 02:35:01
Message: <web.3f23726b90a9c3a61b99e900@news.povray.org>
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 &lt degrees(atan2(Norm.y,Norm.z), ... etc.) &gt }'
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

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