GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Download
  • News
  • Community
  • Resources
  • Language Reference
  • SmallBASIC Manual

This view

  • Original page
  • New address

GeezerVison is showing smallbasic.github.io — SmallBASIC | INTERSECT

Edit History

INTERSECT

INTERSECT Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, BYREF type, BYREF Rx, BYREF Ry

Home > Reference > Math

Calculates the intersection of two line segments AB and CD given by the point Ax, Ay, Bx, By and Cx, Cy, Dx, Dy.

Returns:

  • Rx, Ry = coordinates of crossing point.
  • type = cross-type:
    • 0: No cross (R = external cross)
    • 1: One cross
    • 2: Parallel
    • 3: Parallel (many crosses)
    • 4: The cross is one of the line segments edges.

Example

' Line segment AB
Ax = 50
Ay = 50
Bx = 100
By = 100

' Line segment CD
Cx = 100
Cy =  50
Dx =  50
Dy = 100

intersect Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, type, Rx, Ry

print "Intersection at x = "; Rx; ", y = "; Ry

' Draw lines and a circle at the calculated crossing point
line Ax, Ay, Bx, By color 5
line Cx, Cy, Dx, Dy color 8
circle Rx,Ry, 5 color 12
Code samples using INTERSECT
intersect of 2 circles.bas   intersect of 2 circles.bas   raycaster.bas   raycaster.bas   xy intersect.bas   XY intersect.bas  
Math
ABS   ABSMAX   ABSMIN   ACOS   ACOSH   ACOT   ACOTH   ACSC   ACSCH   ASEC   ASECH   ASIN   ASINH   ATAN   ATAN2   ATANH   ATN   CEIL   COS   COSH   COT   COTH   CSC   CSCH   DEG   DERIV   DETERM   DIFFEQN   EXP   EXPRSEQ   FIX   FLOOR   FRAC   INT   INTERSECT   INVERSE   LINEQN   LOG   LOG10   M3APPLY   M3IDENT   M3ROTATE   M3SCALE   M3TRANS   MAX   MIN   POLYAREA   POLYCENT   POLYEXT   POW   PTDISTLN   PTDISTSEG   PTSIGN   RAD   RND   ROOT   ROUND   SEC   SECH   SEGCOS   SEGLEN   SEGSIN   SEQ   SGN   SIN   SINH   SQR   STATMEAN   STATMEANDEV   STATMEDIAN   STATSPREADP   STATSPREADS   STATSTD   SUM   SUMSQ   TAN   TANH   TRANSPOSE  
This page was last edited on Wed, 19 Apr 2023 15:52:53 +0200 | Markdown processed with pandoc 3.1.12.1
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.