Dim curvepoints As Point()
Dim curvepoints() As Point
ReDim Preserve curvepoints(t) curvepoints(t) = Point(t, sc)
Public Class Form1 Private vertext() As PointF Private Function DegreeToRad(ByVal deg As Integer) As Double 'traduit les degrée en radian Return deg * Math.PI / 180 End Function Private Sub DrawCurves(ByVal gr As System.Drawing.Graphics) Dim mypen As New Pen(Color.DarkBlue, 2) For iter = 0 To 600 ReDim Preserve vertext(iter) vertext(iter).X = iter Try vertext(iter).Y = Convert.ToSingle(Math.Sin(DegreeToRad(iter * 10))) * Convert.ToSingle(Math.Sin(DegreeToRad(iter))) * Convert.ToSingle(Math.Cos(DegreeToRad(iter * 2))) * 50 + Me.Height \ 2 If iter > 0 Then gr.DrawLine(mypen, vertext(iter - 1).X, vertext(iter - 1).Y, vertext(iter).X, vertext(iter).Y) End If Catch ex As Exception End Try Next End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint DrawCurves(e.Graphics) End Sub End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionpublic Class Form1 Private vertext() As PointF Private Function DegreeToRad(ByVal deg As Integer) As Double 'traduit les degrée en radian Return deg * Math.PI / 180 End Function Private Sub DrawCurves(ByVal gr As System.Drawing.Graphics, ByVal mypanel As Panel) Dim mypen As New Pen(Color.DarkBlue, 2) For iter = 0 To 600 ReDim Preserve vertext(iter) vertext(iter).X = iter Try vertext(iter).Y = Convert.ToSingle(Math.Sin(DegreeToRad(iter * 10))) * Convert.ToSingle(Math.Sin(DegreeToRad(iter))) * Convert.ToSingle(Math.Cos(DegreeToRad(iter * 2))) * 50 + mypanel.Height \ 2 If iter > 0 Then gr.DrawLine(mypen, vertext(iter - 1).X, vertext(iter - 1).Y, vertext(iter).X, vertext(iter).Y) End If Catch ex As Exception End Try Next End Sub Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint DrawCurves(e.Graphics, DirectCast(sender, Panel)) End Sub End Class
ReDim Preserve curvepoints(t) curvepoints(t) = Point(t, sc)
curvepoints(t) = Point(t, sc)
Dim curvepoints() As Point
Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint DrawCurves(e.Graphics, DirectCast(sender, Panel)) End Sub
Dim curvepoints As Point()
Dim curvepoints() As Point
for i = 0 to 100 redim preserve curvepoints(i) curvepoints(i).X = abscissa curvepoints(i).Y = coordinates
Public Class Form1 Dim g As Graphics Dim curvepoints() As PointF Public Function DegreeToRad(ByVal deg As Integer) As Double Return deg * Math.PI / 180 End Function Public Sub DrawCurves(ByVal gr As System.Drawing.Graphics, ByVal mypanel As Panel) Dim blackPen As New Pen(Color.Black) Dim t, sc As Single Dim k, ord As Integer Dim f0, T0, amp, moy As Single T0 = CType(TextBox1.Text, Single) / 1000 'conversion de la période en (ms) f0 = 1 / T0 amp = CType(TextBox2.Text, Single) 'amplitude moy = CType(TextBox3.Text, Single) 'moyenne ord = CType(TextBox4.Text, Integer) 'ordre For t = 0 To 100 Step 0.1 sc = moy For k = 1 To ord sc = sc + (4 * amp / Math.PI) * Math.Sin(DegreeToRad((2 * k - 1) * 2 * Math.PI * f0 * t)) / (2 * k - 1) Next k ReDim Preserve curvepoints(t) curvepoints(t).X = t curvepoints(t).Y = sc Next t End Sub Public Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint DrawCurves(e.Graphics, DirectCast(sender, Panel)) End Sub End Class
'module pour les declarations Public Module Module1 Public T0, amp, moy, rap, coup, bandemin, bandemax, gain, puissmoy, puissdef As Single Public Cn, an, bn, phin, puls As Single Public ord As Short Public temps(1201) As Integer Public Cnnn(1201), phinnn(1201) As Single Public omegaa(1201) As Single Public Cnfiltre(1201), phinfiltre(1201) As Single Public frequ(1201) As Single Public A, omega, omegac, Q As Single Public i, j, k As Integer Public sc(1200), st(1200), sds(1200), sma(1200), sba(1200) As Single Public Function DegreeToRad(ByVal deg As Integer) As Double Return deg * Math.PI / 180 End Function End Module 'la sub poour la saisie Public Sub valider_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles valider.Click T0 = CType(periode.Text, Single) / 1000 amp = CType(amplitude.Text, Single) ord = CType(ordre.Text, Short) moy = CType(moyenne.Text, Single) If paire.Checked = True Then bn = 0 paire.Enabled = False impaire.Enabled = False End If If impaire.Checked = True Then an = 0 impaire.Enabled = False paire.Enabled = False End If Public Sub carre_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles carre.CheckedChanged Dim t, k, n As Integer rapport.Visible = True Label6.Visible = True Label12.Visible = True If an = 0 Then 'la partie calcul qui me retourne le s(t) enfin For t = 0 To 1200 temps(t) = t For k = 1 To ord n = 2 * k - 1 sc(t) += moy + (4 * amp / (n * DegreeToRad(Math.PI))) * Math.Cos((n * 2 * DegreeToRad(Math.PI) / T0) * temps(t) - (DegreeToRad(Math.PI / 2))) Next k Next t End If If bn = 0 Then For t = 0 To 1200 temps(t) = t For k = 1 To ord n = 2 * k - 1 sc(t) += moy + (4 * amp / (n * DegreeToRad(Math.PI))) * Math.Cos((n * 2 * DegreeToRad(Math.PI) / T0) * temps(t) + 0) Next k Next t End If End Sub 'apres avoir eu le sc(t) l'axe des ordonnées on dessine la courbe (t.sc(t)) Private Sub DrawCurves(ByVal gr As System.Drawing.Graphics, ByVal mypanel As Panel) Dim mypen As New Pen(Color.DarkBlue, 2) For iter = 0 To 1200 ReDim Preserve vertext(iter) vertext(iter).X = iter Try vertext(iter).Y = Convert.ToSingle(sc(iter)) * 10000 + mypanel.Height \ 2 If iter > 0 Then gr.DrawLine(mypen, vertext(iter - 1).X, vertext(iter - 1).Y, vertext(iter).X, vertext(iter).Y) End If Catch ex As Exception End Try Next End Sub Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint DrawCurves(e.Graphics, DirectCast(sender, Panel)) End Sub
j'ai essayé de l'appliquer dans mon programme mais ça tombe mal et je ne sais pas pourquoi cela m'affiche en fin de compte une ligne horizentale et c'est tout