Like a few others on this forum, I’ve been tearing my hair out over 3d rotations. I’ve tried a thousand different things, and always end up with the wrong solution. I’ve tried it Hpr-style and Quat-style, and I’ve been reading everything I can find on the topic of rotation, but everything’s either too simple (“here’s how to rotate on one axis!”) or too complicated (–insert crazy math here–). I’m really at the end of my rope, and I figure that I must be working off a wrong assumption somewhere. Can anyone help?
Here’s a simple example. In space, I have the camera at (0,0,0). I have a point at (20,20,20). What I want is to have the camera rotate to face that point. Now, trig-wise, this is pretty basic. The point is 45 degrees off of every axis (xy, yz, xz). So I naturally started with the noob mistake of saying:
camera.setHpr(-45,45,0)
or
camera.setHpr(-45,45,45) or some combination like that. Obviously, the problem here is that Euler angles are dependent on the order in which they’re applied. I dig it.
On to quaternions. My foray into that didn’t yield much, either. After a week of research and toil, I produced an algorithm that will rotate to a point as long as that point is on one of the planes that the camera is on (e.g. (20, 20, 0), (20, 0, 20), and (0, 20, 20) all work flawlessly), but adding the third dimension throws it out of wack.
Finally, I decided to use NodePath.lookAt() the point, and printed out the HPR values. What I got was this:
VBase3(-45, 35.2644, 0)
So my fundamental question is this: how on earth do I get “35.2644?” What does that represent mathematically? I mean, If I’m going to set a rotation, I need to know what values to set. I have all the angles of everything to everything else (except, obviously the P angle). What am I missing??