Hi All and once again Thx in advance!
I have a function (grabbed from Stack Exchange here:https://gamedev.stackexchange.com/questions/86755/how-to-calculate-corner-positions-marks-of-a-rotated-tilted-rectangle) which does pretty much what I wish. It rotates a point around an origin.
This is the function:
Function TForm1.CalcRotatedPosition(Rx: single; Ry: single; Ox: single;
Oy: single; Angle: single): TPoint;
var
cosine:single;
sine:single;
TmpPoint: TPoint;
NewPoint: TPoint;
begin
cosine:=cos(Angle);
sine:=sin(Angle);
//Translate back from origin
TmpPoint.x:=Round(Rx-Ox);
TmpPoint.y:=Round(Ry-Oy);
//Rotate Point
NewPoint.x:=Round(TmpPoint.x * cosine - TmpPoint.y * sine);
NewPoint.y:=Round(TmpPoint.x * sine + TmpPoint.y * cosine);
//Translate Back To origin
TmpPoint.x:=Round(NewPoint.x + Ox);
TmpPoint.y:=Round(NewPoint.y + Oy);
Result:=TmpPoint;
end;
If I use an angle below 1.0 the corners oscillate slightly in and out (not wanted!).
However, at angle:=1.0 it rotates too fast (Using BGRAVirtualScreen). I would like to slow it down but maybe my math is not good enough to work out how!
I have tried hard coding a delay but this does not work (movement too jerky).
What can I do?
[SOLUTION]
Do not Round, use singles works smoothly with Angle=0.02!