Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

[PeasyCam]How to get Up Vector

$
0
0

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?


Viewing all articles
Browse latest Browse all 2896

Trending Articles