用于找出圆周上的像素坐标的算法 [英] algorithm for finding out pixel coordinates on a circumference of a circle
本文介绍了用于找出圆周上的像素坐标的算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我知道圆心的像素坐标,圆的半径和垂直角度,我如何在圆周上找出一定程度的像素值。
基本上,我试图在不同的时间(1点钟,2点钟等)绘制一个时钟的手
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 )
推荐答案
h
是一个浮点数( h = 2.25
)将是02:15,等等)在0和12之间。(cX,cY)
是中心的坐标。 hLength
和 mLength
是时针和分针的长度。
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);
这篇关于用于找出圆周上的像素坐标的算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文