how do i find out pixel value at certain degree on the circumference of a circle if I know the pixel co-ordinates of the center of the circle, radius of the circle ,and perpendicular angle. Basically, I am trying to draw the hands of a clock at various times ( 1 o clock , 2 o clock etc )
From trigonometry, we know that θ1 is related by y1 by the sine function, i.e. sinθ1=y1r, where r is the radius. Thus, we can solve for θ1 and then find θ2. From there we can use the cosine function to find x2 and the sine function to find y2. Save this answer.
Since 2Pi*R = circumference, the running length of diameter of the circle, this is the total amount of pixels you have. Now simply write R = 2000/2*Pi and this will give you the radius. Now you should be able to draw a circle the comprised of 2000 pixels.
The circle area is computed using 3.14 * radius * radius.
Use the Distance Formula to find the equation of the circle. Substitute (x1,y1)=(h,k),(x2,y2)=(x,y) and d=r . Square each side. The equation of a circle with center (h,k) and radius r units is (x−h)2+(y−k)2=r2 .
Let h
be the hour as a floating point number (h=2.25
would be 02:15, etc.) between 0 and 12. (cX,cY)
are the coordinates of the center. hLength
and mLength
are the lengths of the hour and min hands.
// Hour hand
hAngle = 2.0*Pi*h/12.0; // 0..12 mapped to 0..2*Pi
hX = cX + hLength * sin(hAngle);
hY = cY - hLength * cos(hAngle);
// Min hand
mAngle = 2.0*Pi*h; // 0..1 mapped to 0..2*Pi, etc.
mX = cX + mLength * sin(mAngle);
mY = cY - mLength * cos(mAngle);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With