POV-Ray : Newsgroups : povray.advanced-users : Simple one : Re: Simple one Server Time
28 Jul 2024 10:23:36 EDT (-0400)
  Re: Simple one  
From: Chris B
Date: 11 Mar 2006 18:55:28
Message: <44136370$1@news.povray.org>
"Orchid XP v2" <voi### [at] devnull> wrote in message 
news:44133910@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?

Unless you actually need to know the angles you can reorient an object 
without knowing them by using Point_At_Trans(YAxis) or Reorient_Trans(Axis1, 
Axis2) from transforms.inc.

These both rotate the object around an axis perpendicular to the plane that 
both the initial vector and the final vector lie on.

It may be that you will need to orient the object by rotating around 
specific axes, (for example a field gun would need to first be rotated 
around a vertical axis, then around a horizontal axis) then it gets a bit 
more complicated. You'll need to start projecting your 'user-supplied' 
vector back onto a plane that is perpendicular to the first axis of 
rotation. In the field gun example above you would need to project your 
'user-supplied' axis onto the horizontal plane to obtain a vector that you 
can use with Point_At_Trans or Reorient_Trans for your first rotation. 
Projecting the vector onto the horizontal plane is easy because you just set 
the Y component of the vector to 0. If your first rotation is not around x, 
y or z, you may need to use VProject_Plane to obtain a vector for the first 
rotation.

If you really have to know the angles then you need VAngle (or VAngleD for 
working in degrees) to compute the angle between two vectors.

Regards,
Chris B.


Post a reply to this message

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