正弦函数的画法
来源:互联网 发布:网络产品代理 编辑:程序博客网 时间:2024/03/29 17:13
Option Explicit
Dim intrate%, intdeg%, m!, n!
'intrate表示速度 ,intdeg表示sin(x)中x的角度 ,n表示幅值放大的倍数,m表示sin(x)的函数周期倍数
Private Sub Command1_Click()
Call drawaxis(Picture1)
Timer1.Enabled = True
Command2.Caption = "停止"
Command1.Enabled = False
End Sub
Private Sub Command2_Click()
If Command2.Caption = "停止" Then
Command2.Caption = "继续"
Timer1.Enabled = False ' 关闭时钟控件
ElseIf Command2.Caption = "继续" Then
Command2.Caption = "停止"
Timer1.Enabled = True
End If
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
Timer1.Interval = 50
Timer1.Enabled = False
Option1(1).Value = True
Option2(1).Value = True
Option3(1).Value = True
m = 1
n = 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
Timer1.Enabled = False
End Sub
Private Sub drawaxis(picx As PictureBox) '自定义绘制坐标轴过程
Dim x1%, y1%, x2%, y2%, Y%
picx.BackColor = vbWhite '置图片框背景色
picx.Cls ' 清屏
picx.DrawStyle = 0 '置图片框为画实线
x1 = 120 ' 第一点的横坐标
y2 = 120 '第二点的纵坐标
y1 = picx.ScaleHeight - 120 '第一点的纵坐标
x2 = picx.ScaleWidth - 120 ' 第二点的横坐标
Y = picx.ScaleHeight / 2
picx.Line (x1, y1)-(x1, y2), QBColor(0) ' 画y轴,自下而上
picx.Line (x1, Y)-(x2, Y), QBColor(0) ' 画x轴,自左向右
picx.Line (x1 - 50, y2 + 50)-(x1, y2), QBColor(0) '画y轴箭头
picx.Line (x1 + 50, y2 + 50)-(x1, y2), QBColor(0)
picx.CurrentX = 300
picx.CurrentY = 200
picx.Print "Y轴"
picx.Line (x2 - 50, Y + 50)-(x2, Y), QBColor(0) '画x轴箭头
picx.Line (x2 - 50, Y - 50)-(x2, Y), QBColor(0)
picx.CurrentX = x2 - 200
picx.CurrentY = Y + 200
picx.Print "x轴"
End Sub
Private Sub Option1_Click(Index As Integer)
Select Case Index
Case 0
m = 0.5 ' 放大一倍
Case 1
m = 1 ' 幅值不变
Case 2
m = 2 ' 缩小一倍
End Select
End Sub
Private Sub Option2_Click(Index As Integer)
Select Case Index
Case 0
n = 2 ' 幅值放大一倍
Case 1
n = 1 ' 幅值不变
Case 2
n = 0.5 ' 幅值缩小一倍
End Select
End Sub
Private Sub Option3_Click(Index As Integer)
'改变循环语句的循环次数以调整绘制速度
Select Case Index
Case 0 ' 快速
intrate = 20
Case 1
intrate = 8 ' 中速
Case 2
intrate = 2 '慢速
End Select
End Sub
Private Sub Timer1_Timer()
Dim X%, Y%, i%, scaly%
scaly = (Picture1.ScaleHeight - 120) / 4 ' 信号最大值
For i = 1 To intrate
Picture1.CurrentX = 120 ' 获取原点的坐标
Picture1.CurrentY = (Picture1.ScaleHeight) / 2
X = intdeg / 180 * scaly ' 取画点的x坐标
Y = Sin(m * intdeg * 3.141593 / 180) * n * scaly ' 取画点的y坐标
Picture1.PSet Step(X, -Y), vbBlue
intdeg = intdeg + 1
If Picture1.CurrentX > Picture1.ScaleWidth - 120 Then
intdeg = 0
Command2.Value = True ' 相当于按了 command2按钮
Command1.Enabled = True ' 相当于按了 command1按钮
End If
Next
End Sub
- 正弦函数的画法
- 正弦函数的泰勒级数
- 正弦函数的python显示
- matlab 二元函数的画法
- 正弦函数
- 正弦函数的频谱图(FFT)
- 关于指数函数与正弦函数的关系
- Android的Canvas绘制正弦函数图像
- 已知正弦函数表利用拉格朗日插值法计算正弦函数的近似值
- 一个正弦函数、余弦函数、坐标系的实例解析
- vb 正弦函数
- 绘制正弦函数曲线
- 正弦波形函数
- 1053 正弦函数
- 1053: 正弦函数
- 求正弦函数sin(x)的近似值的多项式求解
- 对反正弦函数的泰勒公式的转换加速
- 正弦函数的图形,但数值有问题
- 测试计划的编写
- asp的include包含文件深入使用
- 在linux下为cvs创建用户
- ASP.NET 常用的33种代码
- 使用RadControls的RadMenu控件开发系统菜单
- 正弦函数的画法
- 借刀杀人
- 十个极品笑话 看完后我笑的跟哭似的
- 测试方法
- ExtJs的.NET控件----TabContainer和TabPanel
- C#中的常量
- 自己的博客终于建立了http://hard-blog.cn
- 张瑞敏语录
- 线程,同步与锁————Lock你到底锁住了谁?