View Single Post
Old 02-01-2009, 08:01 PM   #286
rps
Registered
 
Join Date: Oct 2008

Posts: 57
Originally posted by Jim Sachs:
I had to figure out the math (not my strong point) to factor in the milliseconds since the last screen refresh.  
Why are you figuring milliseconds since the last screen refresh? The angle of the second hand (in degrees, with 0 deg = straight up [12 o'clock]) would be:

getSystemTime(systemTime)
numsecs = systemTime.wsecond;
if smoothSecondHand.checked then numSecs = numSecs + (systemTime.wMilliseconds / 1000)
angle = 6 * numsecs // 6 degrees per second

Now that you know the angle of the second hand, you can use normal trig functions to figure out exactly where the hand is supposed to be, at the current time. You don't need to figure out the elapsed time since the last refresh; you only need to know the current time.

Hope this helps, (and makes the clock code easier)

~Ralph S.
rps is offline   Reply With Quote