RAPPRESENTAZIONE
FUNZIONI
Per informazioni
contattare l'autore.
|
Questo programma
consente di visualizzare alcune funzioni trigonometriche
all'interno di un oggetto "picture".
Il codice è stato
scritto durante le mie vacanze ed è con molto piacere che lo
rendo disponibile a quanti vogliano implementare ulteriori funzioni
da aggiungere al programma.
In particolar modo
il codice (Visual Basic 6) è un buon esempio di programmazione per
quanti vogliano approfondire e migliorare le loro conoscenze nel
campo della programmazione.
Di seguito
troverete il codice sorgente con relativi appunti relativi alle
singole funzioni :
Private Sub Command1_Click()
Timer1.Enabled = True
Picture1.Cls
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
End Sub
Sub disegna()
Zoom = Val(Text3.Text)
Picture1.Scale (0, 0)-(Zoom, Zoom)
halt = Picture1.ScaleHeight / 2
amp = Val(Text2.Text)
RADIA = 90 * 3.14 / 180
RADIA1 = -90 * 3.14 / 180
Picture1.DrawStyle = 0
Picture1.Line (0, halt)-(Picture1.ScaleWidth,
halt)
Picture1.DrawStyle = 1
Picture1.Line (0, halt + Sin(RADIA) * amp)-(Picture1.ScaleWidth,
halt + Sin(RADIA) * amp)
Picture1.Line (0, halt + Sin(RADIA1) * amp)-(Picture1.ScaleWidth,
halt + Sin(RADIA1) * amp)
a = Sin(b) * amp
cosf = Cos(b) * amp
y = a + cosf
Z = (a / cosf) * amp
f = Atn(b) * amp
'seno iperbolico hsin
b = b + 0.01
G = 1 / Sin(b)
If Check1.Value = 1 Then
Picture1.ForeColor =
&HFF&
Picture1.PSet (xx, a +
halt)
Label1.Caption =
"sin(x)= " + Format(Sin(b), " 0.###")
End If
If Check2.Value = 1 Then
Picture1.ForeColor = 0
Picture1.PSet (xx, cosf +
halt)
Label2.Caption =
"cos(x)= " + Format(Cos(b), " 0.###")
End If
If Check3.Value = 1 Then
Picture1.ForeColor =
&HFF00&
Picture1.PSet (xx, y +
halt)
Label4.Caption =
"sen(x)+cos(x)= " + Format(y / amp, "0.###")
End If
If Check4.Value = 1 Then
''DISEGNA Z
Picture1.ForeColor =
&H80&
Picture1.PSet (xx, Z +
halt)
Label5.Caption =
"SEN(X)/COS(X) = " + Format(Z, "0.###")
End If
If Check5.Value = 1 Then
''DISEGNA F
Picture1.ForeColor =
&HFF00FF
Picture1.PSet (xx, f +
halt)
Label6.Caption = "ARCTAN(X)
= " + Format(f / amp, "0.###")
End If
If Check6.Value = 1 Then
''DISEGNA g
Picture1.ForeColor =
&HFF00FF
Picture1.PSet (xx, G +
halt)
Label10.Caption = "Cosec(X)
= " + Format(G, "#.###")
End If
Picture1.ForeColor = 0
xx = xx + Val(Text1.Text)
b = b + 0.01
calang = b / (3.14 / 180)
If calang > 360 Then
b = 0
End If
Label3.Caption = Format(calang, "##")
& "°"
If xx > Picture1.ScaleWidth Then
Picture1.Cls
xx = 0
End If
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Call disegna
End Sub
|