LinesIntersect
HitState = LinesIntersect(aX1#, aY1#, aX2#, aY2#, bX1#, bY1#, bX2#, bY2#)
 
Parameters:

    aX1# = The X1 cord of line A
    aY1# = The Y1 cord of line A
    aX2# = The X2 cord of line A
    aY2# = The Y2 cord of line A
    bX1# = The X1 cord of line B
    bY1# = The Y1 cord of line B
    bX2# = The X2 cord of line B
    bY2# = The Y2 cord of line B
Returns:

    HitState = If the lines intersect this function will return a true(1) if not it'll be false (zero)
 

      The LinesIntersect functions checks if two lines are intersecting each other.



FACTS:


      * The intersection point can be read using the GetIntersectX#() /GetIntersectY#() functions.



Mini Tutorial:


      This example draws a line (line A) between a fixed point and the current mouse pointer position. It then checks for an intersect between this line with another fixed line (line B). If the two lines intersect it displays a read circle at the intersection point.


  
  
  Repeat
     Cls RGB(0,0,0)
     
   ; Create the coords for LINE A
     ax1#=20
     ay1#=20
     ax2#=MouseX()
     ay2#=MouseY()
   ; Draw Line A
     Line ax1#,ay1#,ax2#,ay2#
     
     
   ; Create the coords for LINE B
     bx1#=100
     by1#=250
     bx2#=300
     by2#=200
   ; Draw Line B
     Line bx1#,by1#,bx2#,by2#
     
     
   ; Check if Line A and Line B Intersect
     If LinesIntersect(ax1#,ay1#,ax2#,ay2#,bx1#,by1#,bx2#,by2#)
        
        Print "Yes Lines Intersect"
        ix#=GetIntersectX#(0)
        iy#=GetIntersectY#(0)
        
      ; draw a read circle to show the intersection point
        CircleC ix#,iy#,5,1,RGB(255,0,0)
     Else
        Print "Nope these lines dont intersect"
        
     EndIf
     
   ; display the screen and continue the repeat/until loop
     Sync
  Until EscKey()
  




 
Related Info: CirclesIntersect | GetIntersectX# | GetIntersectY# | LineHitShape | LineIntersectCircle | LineIntersectRect | PointInBox | PointIntersectCircle | RayIntersectWorld :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com