2022-03-01 13:04:09 +01:00

55 lines
1.9 KiB
Markdown

---
layout: default
---
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
<h1 id="function-intersect">Function intersect <a href="#function-intersect" title="Permalink">#</a></h1>
Calculates the point of intersection of two lines in two or three dimensions
and of a line and a plane in three dimensions. The inputs are in the form of
arrays or 1 dimensional matrices. The line intersection functions return null
if the lines do not meet.
Note: Fill the plane coefficients as `x + y + z = c` and not as `x + y + z + c = 0`.
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
```js
math.intersect(endPoint1Line1, endPoint2Line1, endPoint1Line2, endPoint2Line2)
math.intersect(endPoint1, endPoint2, planeCoefficients)
```
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
Parameter | Type | Description
--------- | ---- | -----------
`w` | Array &#124; Matrix | Co-ordinates of first end-point of first line
`x` | Array &#124; Matrix | Co-ordinates of second end-point of first line
`y` | Array &#124; Matrix | Co-ordinates of first end-point of second line OR Co-efficients of the plane's equation
`z` | Array &#124; Matrix | Co-ordinates of second end-point of second line OR undefined if the calculation is for line and plane
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
Type | Description
---- | -----------
Array | Returns the point of intersection of lines/lines-planes
<h3 id="throws">Throws <a href="#throws" title="Permalink">#</a></h3>
Type | Description
---- | -----------
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
```js
math.intersect([0, 0], [10, 10], [10, 0], [0, 10]) // Returns [5, 5]
math.intersect([0, 0, 0], [10, 10, 0], [10, 0, 0], [0, 10, 0]) // Returns [5, 5, 0]
math.intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6]) // Returns [7, -4, 3]
```