BARBELITH underground
 

Subcultural engagement for the 21st Century...
Barbelith is a new kind of community (find out more)...
You can login or register.


Joey maths question

 
 
Fist Fun
17:59 / 09.12.02
So you have a clock face and you know the x and y co-ordinates of the centre and the length of the radius - how can you calculate a given co-ordinate that the hands would point to at a certain time eg. 1.45

So, say I had a method that went
g.drawString(x,y,endx,endy)
to draw a hand of the clock, and I had already passed in the attributes radius, hour and minute...how would I work that out? Is this trigonometry?

Anyone want to take a shot at that? *blush*
 
 
Perfect Tommy
20:46 / 09.12.02
I'm assuming you want the hour hand to look right? Like, if it's 12:30, the hour hand is between the 12 and the 1?

It's been about 5 years since I programmed anything, but I assume the easiest thing to do would be:

1) Turn the time into a number of minutes past 12:00. If h is the hour and m is the minutes, this is 60*h+m, which I'll call H.

2) Each minute is 6 degrees apart, so you're interested in 6H, and 6m.

3) (I'm assuming your computer's trig functions want degrees, and not radians.) If the length of the clock hand is r, then for the hour hand, your coordinates are x=r*cos(-H+90), y=r*sin(-H+90), and for the minute hand, your coordinates are x=r*cos(-m+90), y=r*sin(-m+90).

At least, I think so =)
 
  
Add Your Reply