|
我在编一个求点集凸包的程序
采点集的程序部分已经搞定
想把点集中y最近小且距x最远的点找到,就用二分法排了序,但数组p()的值纵传不到数组pl()上。请在帮忙看下:
Option Explicit
Private Type pointinfo
x As Single '点的x 坐标值
y As Single '点的y 坐标值
q As Single '与水平线的夹角
End Type
Dim p0 As pointinfo
Dim p(0 To 200) As pointinfo '点集
Dim pl(0 To 200) As pointinfo '求出起始点
Dim ps(0 To 200) As pointinfo '排序后的点集
Dim pi(0 To 200) As pointinfo '极点
Dim n, m, d As Integer
Dim x0, y0 As Single
Dim l, e As Integer
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
DrawWidth = 4
If n = 0 Then
p(0).x = x
p(0).y = y
Circle (x, y), 100, RGB(255, 0, 255)
Else '输入点集
p(n).x = x
p(n).y = y
Circle (x, y), 10, RGB(255, 255, 0)
End If
n = n + 1
x0 = x
y0 = y
End Sub
Private Sub Command2_Click()
Dim i As Integer
Dim q As Single
p(n).x = x0
p(n).y = y0
Const pi = 3.14
Dim u, j As Integer
Dim k, r, f As Integer
Dim term As pointinfo
For u = 0 To n
term = p(l)
k = 0
r = u - 0
Do While k Abs(pl(f).x))) Then
r = f - 1
Else
k = f + 1
End If
Loop
For j = u - 1 To k Step -1
pl(j + 1) = pl(j)
Next j
pl(k) = term
Next u
End Sub
|
|