POV-Ray : Newsgroups : povray.advanced-users : How do you rotate an object to face the origin? : Re: How do you rotate an object to face the origin? Server Time
28 Jul 2024 22:16:03 EDT (-0400)
  Re: How do you rotate an object to face the origin?  
From: Chris B
Date: 16 Dec 2003 11:14:44
Message: <3fdf2f74@news.povray.org>
"Rich" <SrP### [at] ricoswebcom> wrote in message
news:Xns### [at] 204213191226...
> Hi gang,
>     I've searched through the previous posts looking for an answer but
> haven't found one yet.  I need to rotate many objects on their local Y
axis
> so that they face the origin.  The objects are placed randomly, so I don't
> know "where" they are until they are transformed (or just before the
> transform, I suppose).  I've looked at the reorient macro but I don't
think
> that's what I'm looking for.  Can anyone help me with this?
>
> Rich Allen

If you know the targetLocation before you translate the object and the
object is defined at the origin, then you can rotate it before moving it.
If you only need to rotate around the Y axis then the angle is the arctan in
degrees of z / x. So you can use atan2d():

#declare targetLocation = <3,4,5>;
#declare targetAngle = atan2d(targetLocation.z,targetLocation.x);

Hope I understood your question correctly.

Regards,
Chris.


Post a reply to this message

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