# Can Someone help me with my trigonometry rotation, formula? [closed]

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?

## closed as off-topic by Watson, Claude Leibovici, user91500, Chill2Macht, Daniel W. FarlowJul 23 '16 at 16:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Watson, Claude Leibovici, user91500, Daniel W. Farlow
If this question can be reworded to fit the rules in the help center, please edit the question.

• To thank the person who answered your question you should log in, accept the answer (with a check) and vote it up (with an arrow). Please merge your two accounts first as in comment below. – Ethan Bolker Jul 23 '16 at 13:50

## 1 Answer

Whatever program you use to calculate sin uses radians, you should multiply the degree by 2*pi/360, so use sin(degree*2*pi/360) and cos(degree*2*pi/360)