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:19:04 EDT (-0400)
  Re: How do you rotate an object to face the origin?  
From: Rich
Date: 16 Dec 2003 13:09:14
Message: <Xns94537176EB3C0spammindspringcom@204.213.191.226>
"Chris B" <c_b### [at] btconnectcom> wrote in
news:3fdf2f74@news.povray.org: 

> 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.

I think you do understand my question, but when I use your formula I 
don't get the expected results.  I've output the relevant variable values 
and copied them below.  Only one or two of these objects are actually 
pointing at or nearly at the origin...

#declare rotation = atan2d(z1,x1);    
#object {
  thing
  rotate <0,rotation,0> 
  translate <x1,y1,z1>
}


Z:  0.1,  X:  3.5,  Rotation:   1.0
Z:  1.4,  X:  3.0,  Rotation:  25.0
Z:  2.3,  X:  2.0,  Rotation:  49.0
Z:  2.7,  X:  0.8,  Rotation:  73.0
Z:  2.5,  X: -0.3,  Rotation:  97.0
Z:  2.0,  X: -1.2,  Rotation: 121.0
Z:  1.2,  X: -1.7,  Rotation: 145.0
Z:  0.4,  X: -1.8,  Rotation: 169.0
Z: -0.4,  X: -1.6,  Rotation:-167.0
Z: -0.8,  X: -1.1,  Rotation:-143.0
Z: -1.0,  X: -0.6,  Rotation:-119.0
Z: -0.9,  X: -0.1,  Rotation: -95.0
Z: -0.7,  X:  0.2,  Rotation: -71.0
Z: -0.3,  X:  0.3,  Rotation: -47.0
Z: -0.1,  X:  0.2,  Rotation: -23.0


Post a reply to this message

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