在弧上绘制点

时间:2016-05-17 14:43:35

标签: vb.net

我正在制作一个带三角扇的弧形。三角形扇形必须具有每个顶点的设定点以形成弧形。我找到了很多关于DrawArc的文档,但这不是我所追求的,并且在创建" x个点数时找不到任何东西"从A点到B点穿过弧线。

自从我上一次触发课以来已经有好几年了,所以我希望有人知道如何增加A-B之间点的x / y位置。以下是我到目前为止的情况:

Dim points As Integer = 5 ' the number of points between top and right
Dim radius as Integer = 25

' Center point
Dim cx As Integer = loc.X + (size.Width - (radius))
Dim cy As Integer = loc.Y + thickness

' Top point
Dim x1 As Integer = loc.X + (size.Width - (radius))
Dim y1 As Integer = loc.Y

' Right point
Dim x2 As Integer = loc.X + (size.Width)
Dim y2 As Integer = loc.Y + radius

Dim trifan As New VertexArray(PrimitiveType.TrianglesFan)

trifan .Append(New Vertex(New Vector2f(cx, cy), col2)) ' Center point
trifan .Append(New Vertex(New Vector2f(x1, y1), col1)) ' Top point

For i = 1 To points

    ' append other points here...

Next

trifan .Append(New Vertex(New Vector2f(x2, y2), col1)) ' Right point

1 个答案:

答案 0 :(得分:0)

我只是在这里张贴这个,所以它会为遇到它的人提供答案。我在这里得到了很多帮助(按照建议):https://math.stackexchange.com/questions/1789110/plot-points-on-an-arc

    For i = 0 To points - 1

        Dim x As Double
        Dim y As Double
        Dim t As Double = (PI / 2) * (i / points - 1)

        x = cx + Cos(t) * (radius)
        y = cy + Sin(t) * (radius)

        trifan1.Append(New Vertex(New Vector2f(x, y), col1))

    Next