在给定角度和半径的圆上找到点

时间:2015-10-22 09:35:14

标签: vb.net drawing

我使用下面的代码绘制一个矩形,一个半径为200的矩形内圆,一个中心点(300,300)然后我在中心点绘制一个点,一个度数是90,但结果不是我想。我使用公式:

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()

以下是代码:

.circle {
    border: 2px solid red;
    background-color: #FFFFFF;
    height: 100px;
    border-radius:50%;
    width: 100px;
}

结果是

actual results

为什么不(因为我使用90度):

expected results

此外,我想在坐标上的圆上计算位置点(x,y),如下图所示。我该怎么做?我可以申请什么公式?

final desired result

1 个答案:

答案 0 :(得分:3)

Math.Sin和Math.Cos使用弧度,而不是度数。尝试: Dim xtem As Double = pCenter.X + 200 * Math.Cos(90 * Math.PI / 180) Dim ytem As Double = pCenter.Y + 200 * Math.Sin(90 * Math.PI / 180)

这些是圆上一个点的x和y坐标。

相关问题