ЕЧТМ
МгЙизЂ
ЮТмАЬсЪОЃЁгЩгкаТРЫЮЂВЉШЯжЄЛњжЦЕїећЃЌФњЕФаТРЫЮЂВЉеЪКХАѓЖЈвбЙ§ЦкЃЌЧыжиаТАѓЖЈЃЁСЂМДжиаТАѓЖЈаТРЫЮЂВЉЁЗ  |  ЙиБе

# miaozk2006

ЕуЕЮЛ§РлгыЪеВи:ЙигкММЪѕЃЌЙигкЩњЛю

## ШежО

ЮФеТЗжРр

### vbЧѓШЮвтСНЯпНЛЕу

2012-06-05 14:43:41|  ЗжРрЃК БрГЬ-VB |  БъЧЉЃК |ОйБЈ |зжКХДѓжааЁ

ЯТдиLOFTER ЮвЕФееЦЌЪщ  |

ДњТыЃК

Option Explicit

Private Type Point
X As Double
Y As Double
End Type

Private Type Lines
P1 As Point
P2 As Point
End Type

Const CROSS As Long = 0 'ЯрНЛ
Const COLINE As Long = 1 'ЙВЯп
Const PARALLEL As Long = 2 'ЦНаа

Private Function GetPoint(L1 As Lines, L2 As Lines, P As Point) As Long
Dim A1 As Double, B1 As Double, C1 As Double
Dim A2 As Double, B2 As Double, C2 As Double
Dim D As Double, R As Double

A1 = L1.P2.Y - L1.P1.Y
B1 = L1.P1.X - L1.P2.X
C1 = L1.P2.X * L1.P1.Y - L1.P1.X * L1.P2.Y

A2 = L2.P2.Y - L2.P1.Y
B2 = L2.P1.X - L2.P2.X
C2 = L2.P2.X * L2.P1.Y - L2.P1.X * L2.P2.Y

D = A2 * B1 - A1 * B2
'Debug.Print A1; B1; A2; B2; C1; C2
If D = 0 Then
If (A1 = A2) And (B1 = B2) Then
GetPoint = COLINE
Else
GetPoint = PARALLEL
End If
Else
P.X = (C1 * B2 - C2 * B1) / D
P.Y = (A1 * C2 - A2 * C1) / D
GetPoint = CROSS
End If
End Function

'ВтЪд
Private Sub Command1_Click()
Dim L1 As Lines, L2 As Lines
Dim Pot As Point
Dim R As Long

With L1
.P1.X = -10
.P1.Y = -10
.P2.X = 20
.P2.Y = 20
End With

With L2
.P1.X = 10
.P1.Y = 10
.P2.X = -20
.P2.Y = 20
End With
'PLine L1
'PLine L2
R = GetPoint(L1, L2, Pot)
If R = CROSS Then
MsgBox "X: " & Pot.X & " Y: " & Pot.Y
Else
MsgBox Choose(R, "ЙВЯп", "ЦНаа")
End If

End Sub

`еЊздЃКhttp://topic.csdn.net/u/20080503/10/b7b48c43-9137-4e0d-9450-072aa43b52eb.html`

ЧѓСНжБЯпНЛЕуГЬађ [vCдДТы]

еЊздЃКЭјТчећРэ

ЁяVBВПЗжЯрЙиЮФеТЭЦМіЃКЁя

ЁюVBзЅЭМ

ЦРТлетеХ

дФЖС(872)| ЦРТл(0)

#### ЦРТл

<#--зюаТШежОЃЌШКВЉШежО--> <#--ЭЦМіШежО--> <#--в§гУМЧТМ--> <#--ВЉжїЭЦМі--> <#--ЫцЛњдФЖС--> <#--ЪзвГЭЦМі--> <#--РњЪЗЩЯЕФНёЬь--> <#--БЛЭЦМіШежО--> <#--ЩЯвЛЦЊЃЌЯТвЛЦЊ--> <#-- ШШЖШ --> <#-- ЭјвзаТЮХЙуИц --> <#--гвБпФЃПщНсЙЙ--> <#--ЦРТлФЃПщНсЙЙ--> <#--в§гУФЃПщНсЙЙ--> <#--ВЉжїЗЂЦ№ЕФЭЖЦБ-->