simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

intersect.md (1572B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function intersect
      4 
      5 Calculates the point of intersection of two lines in two or three dimensions
      6 and of a line and a plane in three dimensions. The inputs are in the form of
      7 arrays or 1 dimensional matrices. The line intersection functions return null
      8 if the lines do not meet.
      9 
     10 Note: Fill the plane coefficients as `x + y + z = c` and not as `x + y + z + c = 0`.
     11 
     12 
     13 ## Syntax
     14 
     15 ```js
     16 math.intersect(endPoint1Line1, endPoint2Line1, endPoint1Line2, endPoint2Line2)
     17 math.intersect(endPoint1, endPoint2, planeCoefficients)
     18 ```
     19 
     20 ### Parameters
     21 
     22 Parameter | Type | Description
     23 --------- | ---- | -----------
     24 `w` | Array &#124; Matrix | Co-ordinates of first end-point of first line
     25 `x` | Array &#124; Matrix | Co-ordinates of second end-point of first line
     26 `y` | Array &#124; Matrix | Co-ordinates of first end-point of second line OR Co-efficients of the plane's equation
     27 `z` | Array &#124; Matrix | Co-ordinates of second end-point of second line OR undefined if the calculation is for line and plane
     28 
     29 ### Returns
     30 
     31 Type | Description
     32 ---- | -----------
     33 Array | Returns the point of intersection of lines/lines-planes
     34 
     35 
     36 ### Throws
     37 
     38 Type | Description
     39 ---- | -----------
     40 
     41 
     42 ## Examples
     43 
     44 ```js
     45 math.intersect([0, 0], [10, 10], [10, 0], [0, 10])              // Returns [5, 5]
     46 math.intersect([0, 0, 0], [10, 10, 0], [10, 0, 0], [0, 10, 0])  // Returns [5, 5, 0]
     47 math.intersect([1, 0, 1],  [4, -2, 2], [1, 1, 1, 6])            // Returns [7, -4, 3]
     48 ```
     49 
     50