At the moment im coding a 2D Radar for a game called Assault Cube.
First of all i have to say that i got very far in this project , but now i'm at a point where i need help.
I need the calculation to rotate a point(Enemy) around a central point(me). Yesterday i got a calculation (i don`t know the site anymore), but i think it don`t need credits, because math is universal.
Conversion from World to Radar Point
Code:
Private Function ConvertWorldPointToRadarPoint(ByVal X As Single, ByVal Y As Single) As Point
Dim sx, sy As Int32 'X/Y distance between us and enemy (multiplied by zoom)'
Dim x2, y2 As Single
Dim rot As Single = P1Yaw * ((2 * PI) / 360) 'Degree to Radian'
Dim localPlayerX As Single = P1X
Dim localPlayerY As Single = P1Y
sx = Convert.ToInt32((localPlayerX - X) * (NumericUpDown1.Value / 2) + (Me.Width / 2))
sy = Convert.ToInt32((localPlayerY - Y) * (NumericUpDown1.Value / 2) + (Me.Height / 2))
'Maybe left handed system used???? X increases to left?'
x2 = Convert.ToSingle((Me.Width / 2) + (Math.Cos(rot)) * (sx - (Me.Width / 2)) - Math.Sin(rot) * (sy - (Me.Width / 2))) 'rotate a point around a central point'
y2 = Convert.ToSingle((Me.Height / 2) + (Math.Sin(rot)) * (sx - (Me.Height / 2)) + Math.Cos(rot) * (sy - (Me.Height / 2)))
Return New Point(x2, y2)
End Function
Here is a Vid which shows my Radar:
I put in some Youtube music, because i dont want you to hear my crapy Skype conversation ;D







