|
-
Dec 23rd, 2000, 03:49 AM
#1
Thread Starter
Frenzied Member
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.
-
Dec 23rd, 2000, 06:17 AM
#2
Hyperactive Member
LINE COLLISION
Let line1.name = lne1
Let line2.name = lne2
Code:
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.
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Dec 23rd, 2000, 12:33 PM
#3
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|