Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Angles

 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Say there is a camera at (-3,-3,3) in 3d space. We want this camera to point at the origin. If I rotate on the x-axis by 45 degrees (in right-handed space), the x-axis is dead center. If I rotate by -45 degrees (in RH space) on the y-axis, the y-axis is dead center. If I rotate both the x-axis by 45 degrees and the y-axis by 45 degrees, y-axis is correctly centered, but the x-axis seems a bit low, maybe 2/3 down the screen. This could be a problem specific to OpenGL, or specific to my code, but maybe there's a general explanation as to why this happens in 3d space.

it's driving me bat-shit.

For the sake of completeness, my method in Camera is as follows:



One problem I've just discovered about this method is that in a situation where z is negative, both xrot and yrot will "turn around" to look at it, leading to bad angles. I'll takle this once I figure out why a simple angle's not looking right.
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh! Once I've looked up on the x-axis, the triangle for the y-axis is change in x and the hypotenuse of the x-rotation triangle!
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case anyone's curious, here's the correct method:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic