我使用下面的代码绘制一个矩形,一个半径为200的矩形内的圆,一个中心点(300,300),然后在中心点绘制一个点基一度是90度,但结果不是我想要的。我用下式:在给定角度和半径的圆上找到点
x = centerX + radius * cos(degrees)
y = centerY + radius * sin(degrees)
下面是代码:
Dim CAVtable As New Hashtable
Dim oCanvas As New Bitmap(507, 507)
Dim graphicsObj As Graphics = Graphics.FromImage(oCanvas)
graphicsObj.Clear(Color.White)
Dim pCenter As New Point(300, 300)
DrawPoint(pCenter, graphicsObj, Color.Blue)
Dim rc2 As New Rectangle(pCenter, New Size(1, 1))
Dim penARC2 As New Pen(Color.Red, 2)
rc2.Inflate(200, 200)
graphicsObj.DrawRectangle(Pens.Black, rc2)
graphicsObj.DrawArc(penARC2, rc2, 0, 360)
Dim xtem As Double = pCenter.X + 200 * Math.Cos(90.0!)
Dim ytem As Double = pCenter.Y + 200 * Math.Sin(90.0!)
Dim ptem As New Point(xtem, ytem)
DrawPoint(ptem, graphicsObj, Color.Blue)
Response.ContentType = "image/jpeg"
oCanvas.Save(Response.OutputStream, ImageFormat.Jpeg)
Response.End()
graphicsObj.Dispose()
oCanvas.Dispose()
结果是
为什么不能(因为我用90度):
还有,我想要计算坐标圆上的位置点(x,y),如下图所示。我该怎么做?我可以申请哪些配方?
我看到的结果不是度数是90,我不知道! –