|
![](/i/fill.gif) |
Karsten Senz wrote in message <36A5AEE2.C729BC05@wi-bw.tfh-wildau.de>...
>Phil Clute wrote:>> object. I know, I know rotate is the obvious answer,
but it would be>> cool if I could>> use a vector like look_at in camera{}so
that I could just specify a>So you have the position of "your" eye:
<eye_x,eye_y, eye_z>>and you have that stare_at point
<stare_at_x,stare_at_y,stare_at_z>>length_x = stare_at_x - eye_x;>length_z =
stare_at_z - eye_z;>rotation_y = atan2(length_z,length_x);>length_y =
stare_at_y - eye_y;>rotation_z = atan2(length_y,length_x);
Shouldn't that be something like:
#declare Eye_D = Eye_Stare_At - Eye_Location; // vector difference
object { Eye // at origin, looking along +z axis
rotate <-degrees(atan2(Eye_D.y, vlength(Eye_D*<1,0,1>)), // height (note
negation)
degrees(atan2(Eye_D.x, Eye_D.z))+(Eye_D.z<0 ? 180:0), // direction
0> // no rotation around z-axis anymore
translate Eye_Location
}
I'm not quite sure about that y-component - it might look in the wrong
direction
if Eye_D.z is exactly 0. Anyway, the point is to do the rotation around the
y-axis (or whatever is your sky vector) last.
--
Ilmari Karonen (ilt### [at] sci fi)
http://www.sci.fi/~iltzu/
Post a reply to this message
|
![](/i/fill.gif) |