Hi all,
I want to rotate a polygon around one point of that polygon.
The point of rotation is p2(pivotr).
I use the folowing code:
This works, but the polygon gets deformed because i don't know how to calculate the other two points. I am not such a math wizz.
Can someone help me with my calculation, or is there a better way, like RotateTransform, but I have no clue how to use it.
Thanks in advance,
Groover.
I want to rotate a polygon around one point of that polygon.
The point of rotation is p2(pivotr).
I use the folowing code:
VB.NET:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles Me.Paint
Dim myPenF As New Pen(Color.OldLace, 5)
myPenF.Alignment = PenAlignment.Center
myPenF.LineJoin = LineJoin.Round
Dim mybrushF As New SolidBrush(Color.OrangeRed)
Dim p1 As New Point
p1 = endr
Dim p2 As New Point
p2 = pivotr
Dim p3 As New Point(pivotr.X + 10, pivotr.Y + 20)
Dim p4 As New Point(endr.X, endr.Y + 10)
Dim polygonR As Point() = {p1, p2, p3, p4}
e.Graphics.FillPolygon(mybrushF, polygonR)
e.Graphics.DrawPolygon(myPenF, polygonR)
End Sub
Private Sub flipperRightMoveUp()
For fl = -20 To 40
Dim flipperRightAngle As Double = fl
endr = New Point(pivotr.X - ((Math.Cos(flipperRightAngle * (pi / 180)) * 80)), pivotr.Y - (Math.Sin(flipperRightAngle * (pi / 180)) * 80))
Dim rect As New Rectangle(200, 400, 600, 500)
Invalidate(New Rectangle(200, 400, 600, 500))
Next
End Sub
This works, but the polygon gets deformed because i don't know how to calculate the other two points. I am not such a math wizz.
Can someone help me with my calculation, or is there a better way, like RotateTransform, but I have no clue how to use it.
Thanks in advance,
Groover.