# point-in-triangle

> test whether a point is inside a triangle

Latest version **1.0.1** (published 2014-11-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install point-in-triangle
pnpm add point-in-triangle
yarn add point-in-triangle
bun add point-in-triangle
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2014-11-02 |
| First published | 2014-11-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | test, hit, hittest, collide, collision, collided, collides, inside, point, is, triangle, triangles, tris, 2d, vector |

## Links

- npm: https://www.npmjs.com/package/point-in-triangle
- Repository: https://github.com/mattdesl/point-in-triangle
- Issues: https://github.com/mattdesl/point-in-triangle/issues
- npm.io page: https://npm.io/package/point-in-triangle

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2014-11-02
- 1.0.0 — 2014-11-01

## README

# point-in-triangle

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

Test whether a point is inside a triangle, using barycentric coordinates and [this algorithm from BlackPawn](http://www.blackpawn.com/texts/pointinpoly/).

```js
var inside = require('point-in-triangle')

var triangle = [ [25, 10], [100, 250], [40, 40] ]
console.log(inside([25, 25], triangle))
```

You may also be interested in:

- [triangle-circle-collision](https://www.npmjs.org/package/triangle-circle-collision)
- [line-circle-collision](https://www.npmjs.org/package/line-circle-collision)
- [point-circle-collision](https://www.npmjs.org/package/point-circle-collision)
- [is-clockwise](https://www.npmjs.org/package/is-clockwise)

## Usage

[![NPM](https://nodei.co/npm/point-in-triangle.png)](https://nodei.co/npm/point-in-triangle/)

#### `inside(point, triangle)`

Returns true if the point `[x, y]` is inside the triangle `[ [x1,y1], [x2,y2], [x3,y3] ]`, false otherwise.

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/point-in-triangle/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/point-in-triangle · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
