Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

Angles

Nick George
Ranch Hand
Posts: 815
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
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
In case anyone's curious, here's the correct method: