We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Error in Clock Example (Read 666 times)
Error in Clock Example
Oct 19th, 2007, 11:22pm
 
The "Clock" example will be read an hour off in the back half of the hour; it treats hours as whole numbers when analog clocks have an hour hand that "sweeps" with the minutes.

Code:
float h = map(hour() % 12, 0, 12, 0, TWO_PI) - HALF_PI;

wants to be:

Code:
float h = map(hour() + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2) - HALF_PI;


You can probably get away with the minutes being whole, but if you wanted them to "sweep" with the seconds, that line would look like:

Code:
float m = map(minute() + norm(second(), 0, 60), 0, 60, 0, TWO_PI) - HALF_PI;
Re: Error in Clock Example
Reply #1 - Nov 24th, 2007, 11:23pm
 
Yes, good point. I was just trying to keep the example simple, but I made the change. I also added tick marks around the clock so it's easier to see what's happening. Please have a look.

Casey
Page Index Toggle Pages: 1