VB系统的坐标原点在左上角,X轴的正方向是水平向右,而Y轴的正方向是垂直向下。所以,要绘制三角函数的曲线,自己可以通过改变点坐标的方法来实现,当然,VB.NET提供了相应的方法可以来实现坐标变换,也可以通过VB.Net的Graphics类提供的平移、旋转等转换来实现。
目前创新互联已为上千多家的企业提供了网站建设、域名、网页空间、网站托管、企业网站设计、邵原网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
下面是我通过自己变换实现的示例,提供参考;我的环境是VB.NET 2010
Imports System.Math
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'1,获得一个Graphics对象
Dim MyGraphics As Graphics
MyGraphics = PictureBox1.CreateGraphics
'2,定义一个Pen对象,用于绘制图形(轮廓线)
Dim MyPen As New Pen(Color.Black, 1)
'3,定义一个Brush对象,用于填充图形(如果需要填充的话)
Dim MyBrush As New SolidBrush(Color.Orange)
MyGraphics.DrawLine(MyPen, 0, 200, 700, 200)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'1,获得一个Graphics对象
Dim MyGraphics As Graphics
MyGraphics = PictureBox1.CreateGraphics
'2,定义一个Pen对象,用于绘制图形(轮廓线)
Dim MyPen As New Pen(Color.Black, 1)
'3,定义一个Brush对象,用于填充图形(如果需要填充的话)
Dim MyBrush As New SolidBrush(Color.Orange)
'声明横向和纵向比例变量
Dim Heng As Integer = 20
Dim Zong As Integer = 50
'先获得正弦值,保存到点坐标数组
Dim MyPoints(700) As Point
Dim i As Integer
For i = 0 To 700
MyPoints(i) = New Point(i * Heng, 200 + Sin(i) * Zong)
Next
'采用绘制光滑线连接点的方式绘制曲线
MyGraphics.DrawCurve(MyPen, MyPoints)
End Sub
End Class
显示的效果图:
绝对值是“|”,可以直接显示,同理对数可用log(x)代替,根号和其他不支持显示。
如果要显示数学式子,只能画吧。
计算时可用“^”求幂或求根,“/”表示除法和分数线,还有math类。
注意:参数为动态数组;
Private Function MyF(ByRef d() As Integer)
ReDim d(4, 13) As Integer
Dim i As Integer
Dim j As Integer
Dim n As Integer
Dim MyNum(4) As Integer
For i = 1 To 4
MyNum(i) = 0
Next i
Randomize
For i = 1 To 4
For j = 1 To 13
n = Int(Rnd * 4 + 1)
Do While MyNum(n) = 13
n = Int(Rnd * 4 + 1)
Loop
d(i, j) = n
MyNum(n) = MyNum(n) + 1
Next j
Next i
End Function
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款