Results 1 to 8 of 8

Thread: [2008] Resolved - Drawing spirals using the Graphics object ?

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Location
    UK
    Posts
    127

    [2008] Resolved - Drawing spirals using the Graphics object ?

    I have been trying now for 2 nights to draw spirals in vb.net and its starting to get to me now :0(

    Here's a link to the formula ...

    http://www.mathematische-basteleien.de/spiral.htm

    here's what i was trying todo ...

    the code below is just drawing points which i was later going to edit to connect from point to point as soon as i got the spiral function working.

    Code:
        Function Draw()
            Dim iImageCenterPointH As Integer = pbOut.Height / 2
            Dim iImageCenterPointW As Integer = pbOut.Width / 2
            Dim iCircleSpace As Integer = 10
            '# x²+y² = R² or [y = sqr(R²-x²) und y = -sqr(R²-x²)]
    
            Dim oGrapics As System.Drawing.Graphics
            Dim myImage As New Bitmap(pbOut.Width, pbOut.Height)
            pbOut.Image = myImage
    
            oGrapics = pbOut.CreateGraphics
    
    
            For i As Integer = 0 To 100 Step 5
                Dim x, y, r As Integer
    
                '# step 1 >>
                x = i
                y = 0
                r = (y * y) + (x * x)
                r = Math.Sqrt(r)
                myImage.SetPixel(iImageCenterPointW + r, iImageCenterPointH, Color.Black)
    
                '# step 2 >^
                x = i
                y = i
                r = (y * y) + (x * x)
                r = Math.Sqrt(r)
                myImage.SetPixel(iImageCenterPointW + (r / 2), iImageCenterPointH + (r / 2), Color.Black)
    
                '# step 3 ^^
                x = 0
                y = i
                r = (y * y) + (x * x)
                r = Math.Sqrt(r)
                myImage.SetPixel(iImageCenterPointW, iImageCenterPointH + r, Color.Black)
    
                '# step 4 ^^
                x = i
                y = -i
                r = (y * y) + (x * x)
                r = Math.Sqrt(r)
                myImage.SetPixel(iImageCenterPointW - (r / 2), iImageCenterPointH + (r / 2), Color.Black)
    
                x = -i
                y = i
                r = (y * y) + (x * x)
                r = Math.Sqrt(r)
                myImage.SetPixel(iImageCenterPointW + (r / 2), iImageCenterPointH - (r / 2), Color.Black)
    
                x = -i
                y = 0
                r = (y * y) + (x * x)
                r = Math.Sqrt(r)
                myImage.SetPixel(iImageCenterPointW - r, iImageCenterPointH, Color.Black)
    
                x = -i
                y = -i
                r = (y * y) + (x * x)
                r = Math.Sqrt(r)
                myImage.SetPixel(iImageCenterPointW - (r / 2), iImageCenterPointH - (r / 2), Color.Black)
    
                x = 0
                y = -i
                r = (y * y) + (x * x)
                r = Math.Sqrt(r)
                myImage.SetPixel(iImageCenterPointW, iImageCenterPointH - r, Color.Black)
            Next
            pbOut.Image = myImage
            Return ""
        End Function
    im not 100% the output is matching the formula here's what im getting atm ...
    Attached Images Attached Images  
    Last edited by illskills; Feb 20th, 2009 at 03:41 PM. Reason: Resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width