求助:Circle 方法画出来的圆,其圆弧上的坐标点怎么计算?
用 Circle 画一个半圆,颜色为黑色。Picture1.Circle (90, 100), 80, vbBlack, 0, 3.14
然后,计算圆弧上的每个坐标点,再用:
Picture1.PSet (X1, Y1), vbRed
设置该点的像素颜色为红色。
理论上,图像上应该不会显示出黑色的圆弧(都被红色覆盖了),要是计算精确的话,红色也不会画在其它地方,只能画在原黑色轨迹上。
请问,我应该如何精确计算,使坐标点完全重合原先的黑色圆弧,(数学水平太差了,三角函数把我搞蒙了)
程序代码:
Private Sub Command1_Click() '错误的计算过程 Dim iColor As Long, P As Long, X1 As Long, Y1 As Long, Radius As Long Dim CentrX As Long, CentrY As Long Dim Pi As Double, Si As Double, Co As Double Dim Radian As Double, Angle As Double, ArcLen As Double, Angle2 As Double Pi = 3.1415926 With Picture1 .Cls .BackColor = vbWhite .ScaleMode = vbPixels End With Radius = 80 Angle = 180 CentrX = 90 CentrY = 100 Picture1.Circle (CentrX, CentrY), Radius, vbBlack, 0, 3.14 ArcLen = Angle * Pi * Radius / 180 Angle2 = (180 * 1) / (Pi * Radius) ArcLen = Angle * Pi * Radius / 180 For P = 0 To Int(ArcLen) Radian = (P * Angle2) * (Pi / 180) Si = Sin(Radian) Co = Cos(Radian) X1 = CentrX - Radius * Co Y1 = CentrY - Radius * Si If Picture1.Point(X1, Y1) = vbBlack Then iColor = vbRed Else iColor = vbGreen Picture1.PSet (X1, Y1), iColor Next End Sub
[此贴子已经被作者于2022-9-8 16:39编辑过]