It looks like you're new here. If you want to get involved, click one of these buttons!
Hi, it's two days that I'm trying to get the up vector of the peasycam with some problem.
I have the pitch, yaw and roll of the camera
float[] rotations = camera.getRotations(); // x, y, and z rotations required to face camera in model space
camera.setRotations(double pitch, double yaw, double roll); // rotations are applied in that order
so x = pitch, y = yaw, z = roll
and following this Stackoverflow question the vector should be:
x = -cos(yaw)sin(pitch)sin(roll)-sin(yaw)cos(roll)
y = -sin(yaw)sin(pitch)sin(roll)+cos(yaw)cos(roll)
z = cos(pitch)sin(roll)
The problem is that when I try to rotate the camera around the y axis the Up Vector change.
If I have the camera at (0,0,400) watching (0,0,0) the Up Vector given by the formula is (0,1,0) while if I rotate the camera at (0,0,-400) watching (0,0,0) the formula give (0,-1,0).
Am I doing something wrong?
Answers
i don't think those are positions though, they are angles, angles around the 3 axes.
but these are positions.
what yaw, pitch, roll are you using in the calculations in the two cases?
runnable example based on the above. press a key, rotate the cube 180 degrees (around y) and press a key again.