math problem
I am trying to write a function that rotates a 3d point in two angles.
This is what I've got but it don't seem to work. when I rotate the x axis the point just rotates in frot of me. The player is 0,0,0.
1 2 3 4 5
|
result.x = rotate.x * cos(d_x * 3.14 / 180) - rotate.y * sin(d_x * 3.14 / 180);
result.y = rotate.x * sin(d_x * 3.14 / 180) + rotate.y * cos(d_x * 3.14 / 180);
result.z = result.y * sin(d_y * 3.14 / 180) + rotate.z * cos(d_y * 3.14 / 180);
result.y = result.y * cos(d_y * 3.14 / 180) - rotate.z * sin(d_y * 3.14 / 180);
|
rotate = the point that I want to rotate
result = the point that I shall return.
d_x = degrees the z-axis shall rotate in
d_y = degrees the x-axis shall rotate in
I don't think I can explain any better becaus I'm getting brainache.
Topic archived. No new replies allowed.