It's right, notice that sin/cos from <cmath> take radian arguments, 1rad ≈ 57deg
to convert degrees to radians, use this relation: Rad = Deg * π / 180
Also notice that you may have to translate the origin of rotation to get what you want ( get the initial coords as if you had to draw your things with (0,0) as center; rotate using the formula; move the resulting coords to where you want the actual center )
Imports System.Math
Public Class Form1
Dim xold As Double
Dim yold As Double
Dim x2old As Double
Dim y2old As Double
Dim theta As Double
Private Sub LineShape1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LineShape1.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start()
' x() ' = x cos ( theta ) - y sin ( theta )
' y() ' = x sin ( theta ) + y cos ( theta ) : y() ' = x sin ( theta ) + y cos ( theta )
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
LineShape1.X1 -= 250
LineShape1.Y1 -= 250
LineShape1.X2 -= 250
LineShape1.Y2 -= 250
theta = 0.05
xold = LineShape1.X1
yold = LineShape1.Y1
x2old = LineShape1.X2
y2old = LineShape1.Y2
LineShape1.X1 = xold * Cos(theta) - yold * Sin(theta)
LineShape1.Y1 = xold * Sin(theta) + yold * Cos(theta)
LineShape1.X2 = x2old * Cos(theta) - y2old * Sin(theta)
LineShape1.Y2 = x2old * Sin(theta) + y2old * Cos(theta)
LineShape1.X1 += 250
LineShape1.Y1 += 250
LineShape1.X2 += 250
LineShape1.Y2 += 250
End Sub
End Class
Now the problem is, its rotating in...well... i dont even know how to describe it :D
Here, i uploaded a .exe to 2shared. link is here :
I bet you are using linux. I think you probably heard about wine?
I cant get you the old coords, couse something is wron with my vb installation, doesn't want to open up project files for some reason. But its in the middle of the screen, approximately 300,300,320,320