Rolling effect when looking at corners with custom rotation function

32 views Asked by At

when i look up in my game, camera rotates at x-axis which is correct, but when looking up-right camera rotates at x-axis then z-axis

here is the code for rotation (from wikipedia):

def rotate(point, angle):
    x, y, z = point
    a, b, c = angle
    a, b, c = math.radians(a), math.radians(b), math.radians(c)
    rx = (cos(b) * cos(c) * x +
          (sin(a) * sin(b) * cos(c) - cos(a) * sin(c)) * y +
          (cos(a) * sin(b) * cos(c) + sin(a) * sin(c)) * z)
    ry = (cos(b) * sin(c) * x +
          (sin(a) * sin(b) * sin(c) + cos(a) * cos(c)) * y +
          (cos(a) * sin(b) * sin(c) - sin(a) * cos(c)) * z)
    rz = ((-sin(b)) * x +
          (sin(a) * cos(b)) * y  +
          (cos(a) * cos(b)) * z)
    return rx, ry, rz

Expected: when looking up-right, camera should rotate at x-axis and then y-axis

0

There are 0 answers