I need to know how to make a shape go from the bottom of the a form to the top win a sin(?) curve(like a curvy line). heres a little diagram:
--Top of form---
/\
/
\
/
\
/
\
/
\
/
---Bottom Of Form---
thanks in advance
Printable View
I need to know how to make a shape go from the bottom of the a form to the top win a sin(?) curve(like a curvy line). heres a little diagram:
--Top of form---
/\
/
\
/
\
/
\
/
\
/
---Bottom Of Form---
thanks in advance
Yes, you can use the sine function to do that (or cosine, which is technically just a phase shifted sine... but that's enough trig). :) Here's a little sample.
Sine functions have a general form of y = (A * sin(Bx)) + C (I didn't use the standard symbols because they don't exist in Courier New). Anyway, the shape of the graph can be changed by changing A B and C. Messing with A will change the amplitude, or how high and low it will go (in this case, how far to the right and left). Messing with B will change the period, and either squash or expand the curve itself (high B = highly squashed wave). Messing with C doesn't change the shape of the curve, but will move its position up or down (again, in this case to the left or right). The smaller the step gets, the smoother the curve will be, since it's just made of points. Since this is a trig function, using multiples of pi in setting the ScaleWidth/Height makes it look better. I'm sure that's more math than you wanted, but this should help. I love physics and chemistry btw. :)Code:Private Sub Form_Load()
Dim i As Single
Dim Pi As Single
'handy little expression for pi
Pi = 4 * Atn(1)
'these are just used to demonstrate
Me.ScaleWidth = 8
Me.ScaleHeight = 8 * Pi
Me.AutoRedraw = True
'by decreasing, it will appear to go upward
For i = Me.ScaleHeight to 0 Step -0.01
Me.PSet (Sin(i) + (Pi / 4), i), vbRed
Next i
End Sub