UnderwareDESIGN

PlayBASIC => Resources => Source Codes => Topic started by: kevin on February 01, 2017, 10:04:32 PM

Title: Compute Line Intersection Point
Post by: kevin on February 01, 2017, 10:04:32 PM

  Compute Line Intersection Point

[pbcode]

      ClipX=200

      ; the clip boundary
      linec ClipX,0,ClipX,400,$00ff00


      ; cords for a line
      X1#=100
      Y1#=100

      X2#=600
      Y2#=300

      ; compute the slope
      Dx#=X2#-X1#
      DY#=Y2#-Y1#
      Slope# = DY#/DX#

      linec x1#,y1#,x2#,y2#,$ff00ff

      // Clip to te Left..  Left most case   
      ClippedX1#=ClipX
      ClippedY1#=y1#+(Slope#*(ClipX-X1#))

      // this point      
      print ClippedX1#
      print ClippedY1#
      
      Circle ClippedX1#,ClippedY1#,3,true
      
      Sync
      waitkey


[/pbcode]



    PlayBASIC HELP FILES: See  MATH Lines Intersect (https://www.playbasic.com/help.php?page=MATH.LINESINTERSECT)