#### Solaire

##### Respected Hacker
Dank Tier VIP
I'm currently trying to get my radar to rotate, and I'm have a lot of trouble with that. Only the top part will rotate, and even then it's way off (Hits 180 degrees from north before I do). I've seen a lot of sources and can't really make sense of the math. A quick explanation, or mentioning any sort of maths I should learn for this would be really useful.

Current calculations:
C++:
``````float Draws[2];
DrawPoints(*MyPlayer.Yaw, CalcAngle(*MyPlayer.Position, *PlayerList[i].Position, *MyPlayer.Yaw), Get2dDistance(*MyPlayer.Position, *PlayerList[i].Position), Draws);

DoMathX = Draws[0];
DoMathY = (sqrt((-(Draws[0] * Draws[0])) + (Draws[1] * Draws[1])));

DrawY = Center - DoMathY;
DrawX = Center - DoMathX;``````
DrawPoints function
C++:
``````void DrawPoints(float YourYaw, float CalcYaw, float Distance, float * DrawXY)
{
DrawXY[0] = CalcYaw - YourYaw;

DrawXY[1] = Distance;
}``````
Calculate Angle function
C++:
``````float CalcAngle(float src[2], float dst[2], float angles)
{
float deltaX = (src[0]) - (dst[0]);
float deltaY = (src[1]) - (dst[1]);

if ((dst[0]) > (src[0]) && (dst[1]) <= (src[1]))
{
angles = atanf(deltaX / deltaY) * -180.0f / pi;
}

else if ((dst[0]) >= (src[0]) && (dst[1]) > (src[1]))
{
angles = atanf(deltaX / deltaY) * -180.0f / pi + 180.0f;
}

else if ((dst[0]) < (src[0]) && (dst[1]) >= (src[1]))
{
angles = atanf(deltaX / deltaY) * -180.0f / pi - 180.0f;
}

else if ((dst[0]) <= (src[0]) && (dst[1]) < (src[1]))
{
angles = atanf(deltaX / deltaY) * -180.0f / pi + 360.0f;
}

if (angles < 0)
angles += 360;

return angles;
}``````
Get2dDistance Function
C++:
``````float Get2dDistance(float Me[2], float You[2])
{
return sqrt(((You[0] - Me[0]) * (You[0] - Me[0])) + ((You[1] - Me[1]) * (You[1] - Me[1])));
}``````

#### Solaire

##### Respected Hacker
Dank Tier VIP
Can't believe I missed that! I'm currently figuring out the math right now, thanks (Btw, I found your code to be very clean and straightforward. Nice job )

Thank you very much, GAFO!

Last edited:

#### GAFO666

##### Hacker
Meme Tier VIP
Can't believe I missed that! I'm currently figuring out the math right now, thanks (Btw, I found your code to be very clean and straightforward. Nice job )

Thank you very much, GAFO!
yeh no problem, I was talking to my Math Teacher on University about that to figure it out tho xD

Attention! Before you post:

99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

• Fill out the form correctly
• Tell us the game name & coding language