Hy, I've finally done this function, but it is not working as spected. Resulting coordinates are sometimes wrong. Any ideas?
In this function: Angle is the angle to rotate, Source is the non-rotated point(x and Y), and Center is the rotation center. I don't know why but I'm getting some problems when the rotation center Y is not the same as the source Y, very weird. I have no idea what is wrong.
Function GetRotationCords:TDrawingPoint(Angle:Float, Source:TDrawingPoint, Center:TDrawingPoint) Local Radius:Double = Sqr((source.X - center.x) ^ 2 + (source.Y - center.Y) ^ 2) Local NewX:Double = Center.X + radius * Cos(angle) Local NewY:Double = Center.Y + radius * Sin(angle) Return CreateDrawingPoint(newx, newy) End Function '---------- Type TDrawingPoint Field X:Float Field Y:Float Function Create:TDrawingPoint(X:Float, Y:Float) Local DP:TDrawingPoint = New TDrawingPoint dp.X = x dp.Y = y Return dp End Function End Type Function CreateDrawingPoint:TDrawingPoint(X:Float, Y:Float) Return TDrawingPoint.Create(x, y) End Function
In this function: Angle is the angle to rotate, Source is the non-rotated point(x and Y), and Center is the rotation center. I don't know why but I'm getting some problems when the rotation center Y is not the same as the source Y, very weird. I have no idea what is wrong.