Here you have to rotation matrices for x, y and z axis, where theta is the rotation angle:
https://wikimedia.org/api/rest_v1/me...12353c970aa2df
Then you can rotate the angle vector by multiplying the rotation matrix with it. For example, assuming your vector is [x, y, z](row vector) and you want to multiply by Rx you get: [x * 1 + y * 0 + z * 0, x * 0 + y * cos + z * sin, x * 0 + y * (-sin) + z * cos] =
[x, y * cos + z * sin, y * (-sin) + z * cos] which is the formula to compute the rotated vector along x axis. Then convert that back to an angle and set it to your entity. In other words, your rotated vector is:
PHP Code:
//get entity angles and convert them to a vector(original in the pseudocode below)
rotated[0] = original[0]
rotated[1] = original[1] * cos(theta) + original[2] * sin(theta)
rotated[2] = original[1] * (-1) * sin(theta) + original[2] * cos(theta)
//convert rotated back to angle and set it to entity
Similarly, by computing the matrix multiplication by hand, you can deduce the formula for rotation along y and z axis. It's easier to compute by hand the multiplication and then just build the vector using the resulted formula than actually creating the matrices and implementing matrix multiplication logic.
__________________