2016-05-17 152 views
-1

我正在用三角形扇子繪製圓弧。三角形風扇必須爲每個頂點設置點以形成弧形。我已經發現了很多關於DrawArc的文檔,但這不是我所追求的,並且在從點A到點B的弧段上創建「x個點數」時找不到任何內容。圓弧上的繪圖點

已經有好幾年了自從我上一次trig類以來,所以我希望有人知道如何增加AB之間點的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 
+0

也許你可以刪除計算部件,並要求在[數學交易所(http://math.stackexchange.com/)你怎麼能得到圓弧中某一點的座標,以其中心,頂點和右點以及角度爲準... –

+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