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.
im not 100% the output is matching the formula here's what im getting atm ...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




Reply With Quote