https://github.com/ayamflow/point-in-line
Returns a point at length `t` on a given line (two points).
https://github.com/ayamflow/point-in-line
Last synced: about 1 year ago
JSON representation
Returns a point at length `t` on a given line (two points).
- Host: GitHub
- URL: https://github.com/ayamflow/point-in-line
- Owner: ayamflow
- Created: 2015-03-21T21:03:34.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-21T21:11:15.000Z (over 11 years ago)
- Last Synced: 2024-04-13T16:15:08.107Z (about 2 years ago)
- Language: JavaScript
- Size: 117 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
point-in-line
===
Returns a point at length `t` on a given line (two points).
`A ----t-------B`
## Installation
`npm i point-in-line --save`
## Usage
`pointInLine(p1, p1, t)`
p1, p2 are point. It can be any object as long as it has `.x` and `.y` properties.
t is a float. Between 0 and 1, the point will be between p1 and p2.
## Exemple
```js
var pointInLine = require('point-in-line');
var center = {
x: window.innerWidth * 0.5,
y: window.innerHeight * 0.5
};
var p = {
x: 127,
y: 43
};
var p1 = pointInLine(center, p, 0.5); // Point at 50% of the line
var p2 = pointInLine(p, center, 2); // point at twice the length of the line
```