tags:

views:

45

answers:

1

Simple code fragment below draws an ellipse on a VB.NET panel. I now need to locate 10 points ON that ellipse, so I can draw small circles along the edge (the final effect will be an elliptical "table" with 10 "seats" around it.

Help filling in the center of my loop below appreciated.

    Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

    Const OFFSET As Integer = -36

    Dim g As Graphics = e.Graphics
    Dim r As Rectangle = Panel1.ClientRectangle
    Dim iAng As Integer


    r.Inflate(OFFSET, OFFSET)
    g.DrawEllipse(Pens.Black, r)

    For i As Integer = 0 To 9
        iAng = i * 36

    Next

End Sub
+2  A: 

If A is the horizontal radius of the ellipse, and B is the vertical radius, then for any given angle R in radians:

X(R) = A * cos(R)

Y(R) = B * sin(R)

So if you take R = 0, 1 * 2pi/10, 2 * 2pi/10....9 * 2pi/10, then you can find ten seats distributed around the ellipse.

mquander