I got some help here a while back to find this function. It's used for identifying an X/Y location (TPoint) around a circle of a center point based on the X/Y of Focus (TPoint), distance from Focus (Integer) and Degrees around Focus (Integer). I've simplified it as much as possible and it works and I'm using it everywhere, except for one little issues now - there's only 360 possible positions. When it's enlarged across the screen, I'm doing a smooth-moving second hand on a clock. It still jumps because there's only 6 possible points between each second tick mark on the clock (1 second = approx. 6 degree range).
How can I modify this function to take a Single instead of an Integer? I'm horrible with math and didn't make this function. I'd like instead of 6 possible points in 1 second to be more like 600 (depending on the user's screen resolution of course).
JD Solutions
How can I modify this function to take a Single instead of an Integer? I'm horrible with math and didn't make this function. I'd like instead of 6 possible points in 1 second to be more like 600 (depending on the user's screen resolution of course).
Code:
function NewPosition(Center: TPoint; Distance: Integer; Degrees: Integer): TPoint;
var
Radians: Real;
begin
//Convert angle from degrees to radians; Subtract 135 to bring position to 0 Degrees
Radians:= ((Degrees - 135) * Pi / 180.0);
Result.X:= Trunc(Distance*Cos(Radians)-Distance*Sin(Radians))+Center.X;
Result.Y:= Trunc(Distance*Sin(Radians)+Distance*Cos(Radians))+Center.Y;
end;
JD Solutions