[Help Request] Rotate a Point around a central point

03/16/2013 16:29 DXStriker#1
Hey E*PvP Community,
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
There is a little mistake in this calulation which i dont know... Maybe there is a left handed system used? X increases to left?

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
03/17/2013 23:49 DXStriker#2
#Push weiß niemand rat?
03/18/2013 03:48 nkkk#3
scheint so als würdest du einfach um 180 grad bzw pi zuviel/zuwenig rotieren, versuch mal " P1Yaw * ((2 * PI) / 360)" zu "PI + P1Yaw * ((2 * PI) / 360)" zu ändern.
03/19/2013 23:24 DXStriker#4
Quote:
Originally Posted by nkkk View Post
scheint so als würdest du einfach um 180 grad bzw pi zuviel/zuwenig rotieren, versuch mal " P1Yaw * ((2 * PI) / 360)" zu "PI + P1Yaw * ((2 * PI) / 360)" zu ändern.
Vielen dank für die Hilfe! Ich habe dadurch eine idee bekommen, bzw. etwas rumprobiert und kann hiermit die Lösung des Problems präsentieren!:

Code:
Dim rot As Single = PI + (P1Yaw + 90) * ((2 * PI) / 360) 'Grad zu Radian'