Recommended Posts

hi again !
I have my own lookAt() routine in my camera code.
Now in that function I can easy caculate the new Facing Vector, but is there also a way to find the Up- and Right-Vector for that facing Vector ?
I think it must be possible, but i dont know how..
Thanks for any help again !
regards
hansi pirman

Share this post

Link to post

Share on other sites

the only thing which is given is the facing vector.there are no angles and so up and right vectors given.

So for example, the facing vector may beVector(0.324324f,0.1234f,0.84565); (lets assume its normalized, i have just put some random values here... now how can i find the up and right vector for this facing vector ?

Share this post

Link to post

Share on other sites

Guest Anonymous Poster

Guest Anonymous Poster

quote:Original post by hansi pirman the only thing which is given is the facing vector.there are no angles and so up and right vectors given.

Do what aggregate said!

You make the UP vector (0, 0, 1) even though it is wrong it doesn''t matter at this stage.

Cross product the FACING and UP vectors and you will get a CORRECT RIGHT vector. Then cross product the FACING and RIGHT vectors and you will get a CORRECT UP vector different from the original (0, 0, 1)

Share this post

Link to post

Share on other sites

quote:Original post by hansi pirman the only thing which is given is the facing vector.there are no angles and so up and right vectors given.

Do what aggregate said!

You make the UP vector (0, 0, 1) even though it is wrong it doesn''t matter at this stage.

Cross product the FACING and UP vectors and you will get a CORRECT RIGHT vector. Then cross product the FACING and RIGHT vectors and you will get a CORRECT UP vector different from the original (0, 0, 1)

Share this post

Link to post

Share on other sites

Sorry guys, but this doesn''t work.. when the facing vector is only rotatet about the x OR the y axis, it works fine when iI use an initial UP Vector of (0,1,0).but if the facing vector was rotated about the x and y axis, then i get some very funky wrong results..

do i have to use other initial values for the up vector, because i''m using opengl (left handed vs. right handed)...

The Vector is always pointing Up (y>=0), but i want i to point down when the facing vector was rotatet about the x axis more then 90°... but if this is the case, the up vector "flips back" and is still pointing up

0

Share this post

Link to post

Share on other sites

If you are actually using a rotation to find the new facing then you run the up vector through the same rotation. The answer given was more for when you arbitrarily assign a new facing. Lookat which was mentioned is a prime example. You don''t rotate to that direction but rather just switch to it. If your Lookat is actually rotating the camera smoothly to point in that direction then just rotate the up vector along with it. It will still be an orthogonal vector as long as it is a linear transform, i.e. uniform scaling with no shear.