VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

a An Analog Clock which is VERY SIMPLE

K. O. Thaha Hussain  (5 Submissions)   Math/Dates   Visual Basic 3.0   Beginner   Wed 3rd February 2021

Thaha Hussain's Clock-Work Formula:
In most of the computer languages, X-axis is taken correctly. But Y-axis in the reverse of the normal Cartisian axis (Y-axis is incremented downword not upword) . So usual analytic manipulations such as, shifting the origin, calculation of polar co-ordinates etc become difficult. Ofcourse, VB has techniques to correct this problem by scaling. But for many lanuages, it is not available! The formula described can be used in any programming language which has inverted Y-axis (C, BASIC etc.).
These are the difficulties faced while deriving the formulae.
1) The Y axis Problem.
2) Polar angles are measured in anti-clockwise direction, while the clock hands are moved in clockwise direction.
3) 'Zero' of polar angle and 'Zero' of Clock Hands causes a difference of 90 degrees.
The following are the Formulae obtained.
Feel free to use the formula for non-commercial purposes. However the Author's name should be accompanied along with the formula.
Thaha Hussain's clock work formula
Hour Hand :
hour_x2 = LengthOfHourHand * Cos(PI/180*(30 * hour - 90)) + midx
hour_y2 = LengthOfHourHand * Sin(PI/180*(30 * hour - 90)) + midy
Minute Hand:
minute_x2 = LengthOfMinuteHand * Cos(PI/180*(6 * minute - 90)) + midx
minute_y2 = LengthOfMinuteHand * Sin(PI/180*(6 * minute - 90)) + midy
Soconds Hand:
second_x2 = LengthOfSecondsHand * Cos(PI/180*(6 * second - 90)) + midx
second_y2 = LengthOfSecondsHand * Sin(PI/180*(6 * second - 90)) + midy
You'll never get a formula simpler than this to move the clock hands!
1) You can use the formulae in any Programming Language without the Co-ordinate adjustment!
2) No problem for hour, even in 24 Hr format!
3) You can adjust the Length of Clock Hands!
4) Shift the clock to anywhere by changing (midx,midy)
5) Create your own custom controls!
6) A variety of other uses in graphics!
Simply Excellent! Right? Please vote for the formulae!

Assumes
In a form place 3 lines (Line1, Line2, Line3) and a timer (Timer1) and a shape (Shape1). Paste the code.

Rate a An Analog Clock which is VERY SIMPLE (32(32 Vote))
a An Analog Clock which is VERY SIMPLE.bas

a An Analog Clock which is VERY SIMPLE Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters