glulookat problem

Started by
4 comments, last by laeuchli 22 years, 6 months ago
Below is my code for looking up. Whenever I use it, it works fine till I get to 90 d, then it start going back down! Anyone know what this could be happening!?!? g_ViewAnglez+=(x*0.017453292519943295769236907684886); eyeVY=-sin(g_ViewAnglez); eyeVZ=cos(g_ViewAnglez); lookDir.y=((eye.y+eyeVY*2)); lookDir.z=((eye.z+eyeVZ*2)); Jesse www.laeuchli.com/jesse/
Advertisement
Well... this seems quite logical since the sin and cos functions (I''m talking about math functions, not C/C++ ones) are like periodical waves. Let''s try some ascii art.

  Here''s the sin function :y          ^   _     |  / \| /   \|/     \+----------------> x    |    \     /    90°   \   /            \_/  |        |       360°       180°   


As you can seen, from 0 to 90° you go up but after that you go down...

hm... I may not have really understood the question...
Remember cos is sin rotated 90deg
...
Prosper/LOADED did answer the question =)




The nightmare travels across the cosmos with his burning mane. The trail of ash that is produced.

?Have a nice day!?

hehe Prosper... thats some sweet ascii art there man
cos is sin TRANSLATED 90 deg. Not rotated :-D
Otherwise it would be going the Y axis.

And laeuchli, you need to take algerbra 2 or something before gfx programming. I`m serious man.

quick reference:
tan/cos/sin are periodic. tan(x) goes to infinity on multiples of either 90 or 180, I forget which.
cos/sin both max out at 1/-1.

I suggest having a struct CAMERA, and using that to store your values. Then modify it whenever/whereever, and in your render function have something like this:

glTranslate(camera.posx,camera.posy,camera.posz);
glRotatef(camera.anglex,1,0,0);
glRotatef(camera.angley,0,1,0);
glRotatef(camera.anglez,0,0,1);

The 3 end parameters to the glRotatef() are the point the rotation is around, relative to the current poition.
Or something like that. Its late and I don`t care to delve into my documentation.

Oh yes.
Learn vector math concepts, along with trigonometry and algerbra 2.

~V''lion

I came, I saw, I got programmers block.
~V''''lion
~V'lionBugle4d
Thanks Prosper/LOADED. I get it, should have figured that out before(Brain was asleep or something :-)).
And laeuchli, you need to take algerbra 2 or something before gfx programming. I`m serious man.
/>
Been there done that. Just needed some reminding about the graph of the sin function. Thanks for the concern though....

This topic is closed to new replies.

Advertisement