Main Menu

Compute Line Intersection Point

Started by kevin, February 01, 2017, 10:04:32 PM

Previous topic - Next topic

kevin


  Compute Line Intersection Point

PlayBASIC Code: [Select]
      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







    PlayBASIC HELP FILES: See MATH Lines Intersect