'点排序(x坐标从小到大,y坐标从小到大)
Function DianPaiXu3(ByRef PList() As Variant)
Dim I As Long
I = UBound(PList)
Dim Pmin As Variant
Dim Temp As Double
Dim J As Long, K As Long, N As Long, M As Long
Dim P1 As Variant
Dim P2 As Variant
Dim P3 As Variant
'按x坐标排序
For J = 0 To I
For K = J + 1 To I
P1 = PList(J)
P2 = PList(K)
If P1(0) >= P2(0) Then
P3 = PList(J) '=P1
PList(J) = PList(K) 'p1=P2
PList(K) = P3 'P2 = P3
End If
Next K
Next J
'对x坐标相等的进行y坐标排序
For J = 0 To I
For K = 0 To I
P1 = PList(J)
P2 = PList(K)
If P1(0) = P2(0) Then
If P1(1) < P2(1) Then
P3 = PList(J) '=P1
PList(J) = PList(K) 'p1=P2
PList(K) = P3 'P2 = P3
End If
End If
Next K
Next J
End Function
Function DianPaiXu3(ByRef PList() As Variant)
Dim I As Long
I = UBound(PList)
Dim Pmin As Variant
Dim Temp As Double
Dim J As Long, K As Long, N As Long, M As Long
Dim P1 As Variant
Dim P2 As Variant
Dim P3 As Variant
'按x坐标排序
For J = 0 To I
For K = J + 1 To I
P1 = PList(J)
P2 = PList(K)
If P1(0) >= P2(0) Then
P3 = PList(J) '=P1
PList(J) = PList(K) 'p1=P2
PList(K) = P3 'P2 = P3
End If
Next K
Next J
'对x坐标相等的进行y坐标排序
For J = 0 To I
For K = 0 To I
P1 = PList(J)
P2 = PList(K)
If P1(0) = P2(0) Then
If P1(1) < P2(1) Then
P3 = PList(J) '=P1
PList(J) = PList(K) 'p1=P2
PList(K) = P3 'P2 = P3
End If
End If
Next K
Next J
End Function
'点排序(同一条直线上的点)
Function DianPaiXu1(ByRef PList() As Variant)
Dim I As Long
I = UBound(PList)
Dim M As Variant
Dim N As Variant
Dim J As Long
Dim L As Long
Dim Temp As Variant
For J = 1 To I
M = PList(J)
For L = J + 1 To I
N = PList(L)
If M(0) + M(1) > N(0) + N(1) Then
Temp = PList(J)
PList(J) = PList(L)
PList(L) = Temp
End If
Next
Next
End Function
Function DianPaiXu1(ByRef PList() As Variant)
Dim I As Long
I = UBound(PList)
Dim M As Variant
Dim N As Variant
Dim J As Long
Dim L As Long
Dim Temp As Variant
For J = 1 To I
M = PList(J)
For L = J + 1 To I
N = PList(L)
If M(0) + M(1) > N(0) + N(1) Then
Temp = PList(J)
PList(J) = PList(L)
PList(L) = Temp
End If
Next
Next
End Function
[本日志由 tiancao1001 于 2009-04-03 09:10 PM 编辑]
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |