January 21, 2021, 02:28:38 AM

Author Topic: [bmx] Lines Intersect by GfK [ 1+ years ago ]  (Read 415 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] Lines Intersect by GfK [ 1+ years ago ]
« on: June 29, 2017, 12:28:42 AM »
Title : Lines Intersect
Author : GfK
Posted : 1+ years ago

Description : .

Code :
Code: BlitzMax
  1. .


Comments :


AndrewT(Posted 1+ years ago)

 Nice job. I just made a line intersection function for the same reason you did, and it turned out near-identical; great minds think alike. ;)Also, you can check for intersection between line segments as opposed to lines as well by checking if the intersection point is between the endpoints of both lines by adding this to the end of your function
Code: [Select]
If Between(X, X1, X2) And Between(Y, Y1, Y2) And Between(X, X3, X4) And Between(Y, Y3, Y4)
                'Line segments intersect, return 1
Return 1
EndIf

        Return 0
Here's the Between function:
Code: [Select]
Function Between:Int(X:Float, B:Float, T:Float)
If T > B
If X > B And X < T
Return 1
EndIf
Else
If X > T And X < B
Return 1
EndIf
EndIf
Return 0
EndFunction
Might slow it down a bit, which is why I made a separate function to check for segment intersection.


GfK(Posted 1+ years ago)

 Thanks for that.  I was going to add that later but you just saved me the trouble. ;)


Difference(Posted 1+ years ago)

 Thanks both.Small error in the code above (that goes unnoticed if you don't need to check for colinear lines )b2 = v1 - (m2 * u2)should be b2 = v1 - (m2 * u1)


RemiD(Posted 6 months ago)

 . [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal