Zhlw.com - 中华龙网

站长资讯通告:
搜索: 您的位置中华龙网 > 计算机网络 > 网络编程 > ASP.NET > 文章列表

正弦函数的绘制的一种方法

作者:bear  来源:转载  发布时间:2006-1-25 16:59:59
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        Dim G As Graphics

        G = PictureBox1.CreateGraphics()

        '移动坐标原点(那么原点下就变成了(20,pictruebox1.height\2))

        G.TranslateTransform(20, PictureBox1.Height \ 2)

        '绘制X轴与Y

        'Y

        G.DrawLine(Pens.Black, 20, -PictureBox1.Height \ 2, 20, PictureBox1.Height \ 2)

        'X

        G.DrawLine(Pens.Black, -20, 0, PictureBox1.Width, 0)

        '正弦函数

        Dim X, Y As Double

        For X = 0 To 400 Step 0.002

            Y = 60 * Math.Sin(2 * 3.1415926 * X / 200)

            G.DrawLine(Pens.Blue, CInt(X), 0, CInt(X), CInt(Y))

            Application.DoEvents()

        Next

        For X = 0 To 400 Step 0.002

            Y = 60 * Math.Sin(2 * 3.1415926 * X / 200)

            G.DrawLine(Pens.Red, CInt(X), 0, CInt(X), CInt(Y))

            Application.DoEvents()

        Next

    End Sub

        用户名: 验证码: 验证码,看不清楚?请点击刷新验证码 (注“”为必填内容。)


文章评论: [ 查看全部 ] 网友评论
关于本站 - 网站帮助 - 广告合作 - 友情连接 - 网站地图