Home > Software engineering >  VB lg coordinate system, two longitudinal axis
VB lg coordinate system, two longitudinal axis

Time:09-18

Have a great god done lg coordinate system?
Ordinate is lg
To the effect of a excel of lg

CodePudding user response:

Does numerical after Log mapping to the Y coordinate later

CodePudding user response:

Idle, writing example, new construction, form bigger point, put a picturebox, a button, and then paste the following code


 
Dim X0 As Long, Y0 As Long 'origin of coordinates coordinates in the picture
Dim lngBorder As Long 'image relative to the empty picture frame distance
Dim XMAX As Double, YMAX As Double 'coordinates on a maximum of XY can say, here the default minimum value is 0, too lazy to haul around a negative number, there is a need to change

Private Sub Command1_Click ()

Picture1. Width=6000
Picture1. Height=6000
Picture1. ScaleHeight=Picture1. Height
Picture1. ScaleWidth=Picture1. Width

Dim test (1 To 10) As a Double
Dim As Integer I
For I=1 To 10
Test (I)=Exp (I + (Rnd () 0.5) * I * 0.3) 'f (I)=Exp (I) in the ln system should be a straight line, a dash of random disturbance to don't be too straight lines
Next
Render test
End Sub

Private Sub Render (data () As Double)

XMAX=10: YMAX=37000 'Y maximum value according to the case, the greatest possible value is exp (10.5)=36315, we take 37000

LngBorder=400
X0=lngBorder: Y0=Picture1. ScaleHeight - lngBorder 'origin of coordinates define

Picture1. Cls

'drawing coordinate systemPicture1. DrawWidth=1
Dim As Long, I j As Long
Picture1. Line (X0 lngBorder/2, Y0) - (Picture1. ScaleWidth lngBorder/2, Y0), vbBlue
Picture1. Line (X0, Y0 + lngBorder/2) - (X0, lngBorder/2), vbBlue

For j=0 To 4
For I=10 ^ j To 10 ^ (j + 1) Step 10 ^ j
Picture1. Line (X0, TRANY (I)) - (Picture1. ScaleWidth lngBorder/2, TRANY (I)), RGB (200, 200, 255)
Next
Picture1. CurrentX=0: Picture1. CurrentY=TRANY (I - 1) - 100: Picture1. Print Trim (Str 10 ^ (I - j))
Next

'
drawing curvePicture1. CurrentX=X0 + LBound (data)/XMAX * (Picture1. ScaleWidth - lngBorder * 2)
Picture1. CurrentY=TRANY (data (LBound (data)))
Picture1. DrawWidth=2
For I=LBound (data) To UBound (data)
Picture1. Line - (X0 + I/XMAX * (Picture1. ScaleWidth - lngBorder * 2), TRANY (data (I))), RGB (255, 0, 0)
Next
'with numerical
For I=LBound (data) To UBound (data)
Picture1. CurrentX=X0 + I/XMAX * (Picture1. ScaleWidth - lngBorder * 2)
Picture1. CurrentY=TRANY (data (I)) + 100
Picture1. Print Round (data (I), 2)
Next
End Sub
Private Function TRANY (ByVal dblIn As Double) As a Double
TRANY=Y0 - (Log (dblIn)/Log (YMAX)) * (Picture1. ScaleHeight - lngBorder * 2)
End the Function




CodePudding user response:

Since the draw is to learn the skills in the morning and evening,
  • Related