camera phi & theta

Started by
3 comments, last by RenderCache 19 years, 6 months ago
hhi! i got a little qn on managing a camera. i parsed truespace's perspective camera, and need to convert it to standard layman usage(TS really inverts the axes all over until i blur). suppose i got arbitrary lookat,up,right,position camera vectors(parsed from TS). But i dunno the phi and theta, which i need to calculate for a 1st person camera. Is there a way to calculate them? thx! RC
Advertisement
you need a matrix-to-euler conversion routine, that converts a matrix into a euler.

google : matrix to euler conversion

...Bookmark the Martin Baker site.

Everything is better with Metal.

as a side note, you can build a orientation matrix by loading the columns (or rows if the matrix is row aligned) of the matrix with the strafe, up, dir vectors you have.

Everything is better with Metal.

I'm not sure which way around your phi and theta are so I'll refer to them as elevation and heading angles. The elevation angle, ie: that between the normalised lookat vector and the xz plane, is given by:

sin( elevation angle ) = lookat.yaxis

and the direction angle, that between the lookat vector and the zy plane, is given by:

sin( direction angle ) = lookat.xaxis

where yaxis and xaxis are the world cartesian axes and '.' refers to the vector dot product. Note that this will give you signed angles. Hope that this is what you were after

Edit: Just occured to me the lookat vector refers to a point in space and not the camera view vector doesn't it. In that case replace lookat vector above with the normalised view vector which is given by subtracting the lookat vector from the camera pos vector and normalising the result. Sorry for the confusion
[size="1"] [size="4"]:: SHMUP-DEV ::
hmm... ok thks!
however, looks like got another weird problem, looks like i din realli get the correct lookat,up,right vectors correctly.

i managed to parse their so called "camera local axes", which kinda seemed to me are the vectors but i think i am lacking something to fit them correctly. The following are the results of the parsing.

camera position 16.6 16.32 13.7
camera local x axis -0.707107 0.707107 0
camera local y axis -0.3987 -0.3987 0.825879
camera local z axis -0.583985 -0.583985 -0.563847

Their actual world axes follows that of mathworld, x-axis goes towards the viewer, y-axis points to the right, z-axis points up.

i am using GL, and i was thinking that the lookat vector is the so called/parsed camera local z-axis, but fitting any of the other 2 vectors for the up and right doesnt give the natural feel of a 1st person camera though...sigh

thx!
RC

This topic is closed to new replies.

Advertisement