PDA

Click to See Complete Forum and Search --> : Maths Stuff


PsyVision
Dec 23rd, 2000, 02:49 AM
Hi,

A few maths questions here. If i have a line that goes from 25,30 to 40,10 and another line moves towards it, how can i find if the end of the line collieds with it:


|
| <-- ----------------
|
|
|
|
|
So how would i work out if the horizontal line hit with the vertical one. Secondally. How would i do the same with too circles ?

Excuse the art work.

Wak
Dec 23rd, 2000, 05:17 AM
Let line1.name = lne1
Let line2.name = lne2


Private Sub Timer1_Timer()
Dim x As Boolean
Dim y As Boolean

If (lne2.X1 < lne1.X2) And ((lne2.X2 > lne1.X1) And (lne2.X2 > lne1.X2)) Then x = True
If (lne2.Y1 > lne1.Y1) Then y = True

If (lne2.X1 > lne1.X2) And (lne2.X2 < lne1.X1) Then x = True
If (lne2.Y2 > lne1.Y1) And (lne2.Y1 < lne1.Y1) And x = True Then y = True

If x = True And y = True Then MsgBox "Colision Detected!"
MsgBox "X: " & x & "Y: " & y
End Sub



I wasn't sure whether the lines where straight or diagonal, but this should work for both.

PsyVision
Dec 23rd, 2000, 11:33 AM
A Reply, Thanks.