 DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

1. Registered User
Join Date
Dec 2006
Posts
1

Hello everyone.
i tried the folowing but its not working.

W = P.Width
H = P.Height
WM = W / 2
HM = H / 2
P.Line (0, HM)-(W, HM), vbRed
P.Line (WM, 0)-(WM, H), vbRed

MAXY = v(0)
For I = 1 To N
If MAXY < v(I) Then
MAXY = v(I)
End If
Next I

MAXX = 5
OX = 0
OY = 0
ScaleX1 = W / N
ScaleY1 = H / N
For I = 0 To N
If v(I) > 0 Then
YT = WM + ((WM * v(I)) / MAXY)
Else
YT = WM - ((WM * -v(I)) / MAXY)
End If
If t(I) > 0 Then
TT = HM + ((HM * t(I)) / MAXX)
Else
TT = HM - ((HM * -t(I)) / MAXX)
End If
OX = OX + ScaleX1
OY = OY + ScaleY1
P.Line -(TT, YT)

Next I  Reply With Quote

2. If it's "quadratic" then "N" must = 3 is it true ?

I just need to know your algorithm to have this shape from array ,
I think line similar to this are not clear :
" YT = WM + ((WM * v(I)) / MAXY) "
After my caluclations this equation generate a "quadratic" form but the problem is to have good matrix .

If u mean that those arrays holds x,y positions so try this will make good work :

Code:
```WM = p.Width / 2
HM = p.Height / 2
p.Line (0, HM)-(W, HM), vbRed
p.Line (WM, 0)-(WM, H), vbRed

For i = 0 To 3
p.Line -(v(i), t(i))
Next```  Reply With Quote

3. Senior Member
Join Date
Aug 2004
Location
Orange, California
Posts
1,263
I can help you by taking your code and creating a simple test project that plots your graph in a picture box; but I need sample data for the V and T arrays. You should select data that you would recognize what the graph should look like. This way if my results look wrong we can figure out what is throwing it off.  Reply With Quote

4. Senior Member
Join Date
Aug 2004
Location
Orange, California
Posts
1,263
Ok I started a simple test project to play around with. It plots the graph and scales it to fit within the picture box. I played around with your code a bit also. Since in VB the X axis is horizontal and the Y axis is veritcal I changed some variable names to refelect this better. Also notice that I set the ScaleMode to pixels so the lines would plot easier. I left your original code in a different sub for reference.
Last edited by Ron Weller; 05-30-2008 at 10:18 PM.  Reply With Quote

5. well, you are doing too much scaling.
VB is great to plot this kind of data, because you can set the scale (both horizontal and vertical) of the printing/displaying object as you wish, using the scale property.
Just use:

myPictureBox.scale = (MinX, MaxY)-(MaxX, MinY)

where the parameters are the range of your coordinate, minimum and maximum, and you do not have to scale anything, just use your coordinate, for example this draw a rectangle in the middle of the form (code to be used in the Paint event unless the AutoRedraw property was set):

Me.Scale (0, 100)-(100, 0)
Me.Line (25, 25)-Step(50, 50), , B

Incidentally, if you put the drawing code in a sub and you pass to it the Graphic object (like a PictureBox or a Printer) you can implement a Printing app with Preview.

Let us know how it goes  Reply With Quote

#### Posting Permissions

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