• FEATURED
• FEATURED
• FEATURED
• FEATURED
• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# glulookat problem

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1laeuchli  Members

Posted 08 October 2001 - 08:17 AM

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/

Posted 08 October 2001 - 01:36 PM

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

### #3GoofProg  Members

Posted 08 October 2001 - 02:06 PM

Remember cos is sin rotated 90deg
...

Posted 08 October 2001 - 03:49 PM

hehe Prosper... thats some sweet ascii art there man

### #5Vlion  Members

Posted 08 October 2001 - 06:32 PM

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

### #6laeuchli  Members

Posted 09 October 2001 - 05:15 AM

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.