Polar Coordinates and Analog Clock Help

  • Thread starter Thread starter Charles Conlow
  • Start date Start date
C

Charles Conlow

Greetings all! I've hit a brain bump here and need a boost...
given this analog clock code (just the hour hand here), where am I missing
the math to move the hour hand along PAST this point? Using this code, it's
drawn AT the hour position, but not PAST it as a real clock does. I'm
thinking too hard about this, perhaps?

Thanks!
Chuck

// draw the HOUR HAND (busted!)
float x_hour = centerx + (int)((centerx * .60) * Math.Sin(2 * Math.PI *
(double)currentTime.Hour / 12));
float y_hour = centery - (int)((centery * .60) * Math.Cos(2 * Math.PI *
(double)currentTime.Hour / 12));
e.Graphics.DrawLine(new Pen(Color.Black,4), centerx, centery, x_hour,
y_hour);
 
not tested but I think where it has "currentTime.Hour / 12" (which essentially
is the degree) you'd need to add how many minutes / 60 so you don't get an
even 12th. So....

(double)currentTime.Hour / 12 + (double)currentTime.Minute / 60

if that doesn't work then somewhere you have to add the minutes :)
 
Thanks... I had been staring at that silly bit of code for too long. Your
response was right on! Simply adding in the additional degree(s) for the
minutes worked perfect. Thanks again!

Chuck
 
Back
Top