drawing the function graphic
Hi friends,
I want to ask a question about drawing a graphic
these are my code
vb Code:
Option Explicit
Const i3 As Integer = 1
Const i2 As Integer = 2
Const i1 As Integer = 1
Const xmin As Integer = -10
Const xmax As Integer = 10
Const ymin As Integer = 0
Const ymax As Integer = 121
Const N As Integer = 20
Private Sub Form_Load()
Dim i As Integer
Dim A As Double
Scale (xmin, ymax)-(xmax, ymin)
Line (xmin, 0)-(xmax, 0)
Line (0, ymin)-(0, ymax)
PSet (xmin, Pol(xmin))
For i = xmin To xmax Step (xmax - xmin) / N
A = Pol(i)
Line -(i, A)
Circle (i, A), 0.005
Next
End Sub
Function Pol(x As Integer) As Double
Dim y As Double
y = i3 * x * x + i2 * x + i1
Pol = y
End Function
This is the graphic which the programme drew
http://img189.imageshack.us/img189/3417/graphic1lx.jpg
This is what I want
http://img259.imageshack.us/img259/2254/graphicn.jpg
What should I do?
Edit: If you also say how I can make the program draw the graphic below, it will be awesome :)
http://img443.imageshack.us/img443/2628/graphic2pv.jpg
I chose x1,y1 randomly to tell what I want to make
Thanks
Re: drawing the function graphic
@_MeRKeZ_
Try to change ymin and ymax to
vb Code:
Const ymin As Integer = -60
Const ymax As Integer = 60
@Nightwalker83
Because the drawing is in Form_Load event, the draw is disappear when showing the form, add Me.AutoRedraw = True at the beginning of the Form_Load code.
Re: drawing the function graphic
Quote:
Originally Posted by
4x2y
@Nightwalker83
Because the drawing is in Form_Load event, the draw is disappear when showing the form, add Me.AutoRedraw = True at the beginning of the Form_Load code.
Yeah, I noticed that after I posted.
Re: drawing the function graphic
Thanks for helping me
Why 0 and 121 cause that problem? Could you explain it?
Can I make the programme draw last graphic?
Re: drawing the function graphic
Quote:
Originally Posted by
_MeRKeZ_
Thanks for helping me
Why 0 and 121 cause that problem? Could you explain it?
Because you are divide the plan to four quarters and at the same time you set xmin, xmax to -10, 10 so y should be the same.
Re: drawing the function graphic
Quote:
Originally Posted by
_MeRKeZ_
Can I make the programme draw last graphic?
Are you want to draw lines according to x1 and y1? if so, try this
vb Code:
Private Sub Command1_Click()
Dim x1 As Double
Dim y1 As Double
x1 = -5.6
y1 = 21
Line (x1, 0)-(x1, y1)
Line (0, y1)-(x1, y1)
End Sub
Re: drawing the function graphic
I want those values to seem on the graphic as I gave the example above