vb怎么将多个点用光滑曲线连起来,并画出这条曲线的平均线最好加上代码 平均线是穿过曲折直线的一条直线,
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/10 03:57:10
vb怎么将多个点用光滑曲线连起来,并画出这条曲线的平均线最好加上代码 平均线是穿过曲折直线的一条直线,
vb怎么将多个点用光滑曲线连起来,并画出这条曲线的平均线
最好加上代码 平均线是穿过曲折直线的一条直线,
vb怎么将多个点用光滑曲线连起来,并画出这条曲线的平均线最好加上代码 平均线是穿过曲折直线的一条直线,
用贝塞尔曲线画就可以了
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function PolyBezierTo Lib "gdi32.dll " (ByVal hdc As Long,lppt As POINTAPI,ByVal cCount As Long) As Long
Private Sub Form_Paint()
Dim pts(0 To 6) As POINTAPI
'set the coördinates
pts(0).x = 22:pts(0).y = 33
pts(1).x = 66:pts(1).y = 55
pts(2).x = 177:pts(2).y = 88
pts(3).x = 199:pts(3).y = 111
pts(4).x = 299:pts(4).y = 222
pts(5).x = 80:pts(5).y = 333
PolyBezierTo Me.hdc,pts(0),6
End Sub
平均线 是个什么线?求出平均值后话直线吗?
那就lineto好了
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function PolyBezierTo Lib "gdi32.dll " (ByVal hdc As Long,lppt As POINTAPI,ByVal cCount As Long) As Long
Private Sub Form_Paint()
Dim pts(0 To 6) As POINTAPI
Dim pt(0 To 6) As POINTAPI
'set the co?rdinates
pts(0).x = 22:pts(0).y = 33
pts(1).x = 66:pts(1).y = 55
pts(2).x = 177:pts(2).y = 88
pts(3).x = 199:pts(3).y = 111
pts(4).x = 299:pts(4).y = 222
pts(5).x = 80:pts(5).y = 333
For n = 1 To 6
pt(n).x = (pts(n).x + pts(n - 1).x) / 2
pt(n).y = (pts(n).y + pts(n - 1).y) / 2
Next n
PolyBezierTo Me.hdc,pt(0),6
PolyBezierTo Me.hdc,pts(0),6
End Sub