I've been working on some code for a game to make a hit box, this question is just about the math though.
Basically I'm trying to rotate an X, Y point(i guess according to the game it's Z,X Not sure if that really matters, pretty sure it doesn't) around another X, Y point, using an angle provided by the games code.
The code/equation uses that angle value (witch is a numerical representation of witch direction the players avatars head is facing.) to rotate and object around the player. It's supposed to match the player turning or, for every rotation the player does the object is supposed to match it with one rotation around the player.
The problem is it's not, it rotates ALOT more than once, I vaguely estimated the player turning 90 degrees, and the objected rotate about 14 times.
From what I can tell from testing the angle provided by the games code is a number from 0 to 360 that resets every time you make it to 0 or 360 and is positive or negative whether you turn left or right (and can randomly equal 100 something? I think that's a glitch)
I have a code but here's the code as more of an equation Were:
If X, Y = the position of an object.
If X1, Y1 = The position the object will be rotating around.
If A = the angle X, Y will be rotated by.
If X2, Y2 = The value of X, Y after their rotated.
tempX = X - X1; tempZ = Y - Y1; rotatedX = tempX*cos(A) - tempZ*sin(A); rotatedZ = tempX*sin(A) + tempZ*cos(A); X2 = rotatedX + X1; Z2 = rotatedZ + Z1;
To restate my problem using this algorithm, were I'm pretty sure A is between 0 and 360, the object will rotate around X1, Y1 more than once, as opposed to the assumed one time, and I only want it to go around one time.
Does anyone know why this isn't working?
Edit: Thanks to TROLLKILLER For the solution, Short version for anyone else having this problem, it probably means that the programs way of calculating cos and sin use radians, instead of angles(probably a better word than angles...)
Ways of fixing this include: Using a different method of sin and cos in the program, ones that are made to use angles.
Use a method in the program to convert the angles to raidian.
Or TROLLKILLER's method, multiply the angles by 2*pi/360 (witch might convert them to radians? I"m not sure but doing this worked for me)
Thanks again :D
Now do I mark this as resolved or... something?