1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
Private Sub command1_Click()
Dim dx As Single
Dim dy As Single
Dim da As Single
Dim db As Single
Dim t As Single
Dim s As Single
Dim t1() As String
Dim ligne() As String
CommonDialog1.ShowOpen
Label1.Caption = CommonDialog1.FileName
filin = Mid(Label1.Caption, 1, Len(Label1.Caption)) & ".INT"
Open filin For Output As #2
Open Label1.Caption For Input As #1
i = 1
While Not EOF(1)
ReDim Preserve t1(i)
ReDim Preserve ligne(i)
Line Input #1, t1(i)
ligne(i) = Mid$(t1(i), 9, 3)
i = i + 1
Wend
For i = LBound(t1) To UBound(t1)
For j = UBound(t1()) To i + 2 Step -1
If ligne(i) <> ligne(j) Then
' resultat = StrComp(ligne(i), ligne(j))
' If resultat <> 0 Then
X1 = Val(Mid$(t1(i), 47, 9))
Y1 = Val(Mid$(t1(i), 57, 9))
X2 = Val(Mid$(t1(i + 1), 47, 9))
Y2 = Val(Mid$(t1(i + 1), 57, 9))
A1 = Val(Mid$(t1(j - 1), 47, 9))
B1 = Val(Mid$(t1(j - 1), 57, 9))
A2 = Val(Mid$(t1(j), 47, 9))
B2 = Val(Mid$(t1(j), 57, 9))
dx = X2 - X1
dy = Y2 - Y1
da = A2 - A1
db = B2 - B1
DIST = Abs(Sqr(Abs((dx * dx + dy * dy))) - Sqr(Abs((da * da + db * db))))
' End If
If (da * dy - db * dx) = 0 Then
' Debug.Print , " The segments are parallel."
Exit Sub
End If
s = (dx * (B1 - Y1) + dy * (X1 - A1)) / (da * dy - db * dx)
t = (da * (Y1 - B1) + db * (A1 - X1)) / (db * dx - da * dy)
If (s >= 0# And s <= 1# And t >= 0# And t <= 1#) And DIST <= 200 Then
'And DIST <= 200
Print #2, t1(i); t1(j), " ", Mid$(t1(i), 67, 5) - Mid$(t1(j), 67, 5)
' print#2,mid$(t1(i),1,13)
End If
End If
Next
Next
Close
End
End Sub |
Partager