0
極座標を使用してピザにペッパーノーズを描こうとしていますが、原点を移動する際に問題があります。ここに私のコードは次のとおりです。ビジュアルベーシックで極座標を使用して描画中の原点を移動する
私はポイントを移動する方法任意のアイデア:
If pTopping = True Then
Dim counter = 0
Dim imgPic(3) As Image
imgPic(0) = pepperoniOne
imgPic(1) = pepperoniTwo
imgPic(2) = pepperoniThree
Do Until counter > 38
Dim value As Integer = CInt(Int((3 * Rnd()) + 0))
Dim i = imgPic(value)
Dim PTC As New polarAndCartesian(CInt(Int((60 * Rnd()) + 0)), CInt(Int((360 * Rnd()) + 0)))
e.Graphics.DrawImage(i, CInt(PTC.X), CInt(PTC.Y))
counter += 1
Loop
End If
そしてここでは、私の結果です:
Public Class polarToCartesian
Property X As Double
Property Y As Double
Sub New(Radius As Double, AngleDegree As Double)
Dim AngleRadian As Double = AngleDegree * 2 * Math.PI/360
X = Radius * Math.Cos(AngleRadian)
Y = Radius * Math.Sin(AngleRadian)
End Sub
End Class
Public Class CartesianToPolar
Property Radius As Double
Property AngleRadian As Double
ReadOnly Property AngleDegree As Double
Get
Return AngleRadian * 360/(2 * Math.PI)
End Get
End Property
Sub New(X As Double, Y As Double)
Radius = (X^2 + Y^2)^0.5
AngleRadian = Math.Atan2(Y, X)
End Sub
End Class
そして、ここでは、私がpepperonisを描いてる方法です私は描画を始める前に極座標上の原点?私はこの1つの周りに私の頭を包んで苦労している。
中心に向かってトッピングをバンチング回避するために、半径が薄暗いR = Math.Sqrt(CDBL 'で選択することができる。
は、.NETに0と2の間のランダムな整数を取得します(rPix - rPepperoni)の最大許容半径です。ここで、 'rand = New Random()'と 'rMax'は最大許容半径です。 Ref:[円内のランダムな点](http://stackoverflow.com/a/29061071/1115360)。 –
ありがとう。私は最後の部分の周りに私の頭を包むことができませんでした...私は極座標を設定することは、私の脳の日に揚げたと思います。 – Dunnage