# line-circle-collision

> line-circle collision test

Latest version **1.1.3** (published 2014-11-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install line-circle-collision
pnpm add line-circle-collision
yarn add line-circle-collision
bun add line-circle-collision
```

## 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.1.3 |
| Published | 2014-11-01 |
| First published | 2014-09-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | line, circle, point, collision, hit, test, hittest, collide, inside, intersect, intersection |

## Links

- npm: https://www.npmjs.com/package/line-circle-collision
- Repository: https://github.com/mattdesl/line-circle-collision
- Issues: https://github.com/mattdesl/line-circle-collision/issues
- npm.io page: https://npm.io/package/line-circle-collision

## Dependencies (1)

- [point-circle-collision](https://npm.io/package/point-circle-collision.md) ^1.0.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2014-11-01
- 1.1.2 — 2014-11-01
- 1.1.1 — 2014-11-01
- 1.1.0 — 2014-09-11
- 1.0.4 — 2014-09-01
- 1.0.3 — 2014-09-01
- 1.0.2 — 2014-09-01
- 1.0.1 — 2014-09-01

## README

# line-circle-collision

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

Performs a line-circle collision test, returning true if they intersect. Algorithm from [2D Game Collision](http://www.amazon.co.uk/2D-Game-Collision-Detection-introduction/dp/1479298123) by Thomas Schwarzl.

```js
var collide = require('line-circle-collision')

var circle = [5, 5],
	radius = 25,
	a = [5, 6],
	b = [10, 10]

var hit = collide(a, b, circle, radius)
console.log(hit)
```

You may also be interested in:

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

## Usage

[![NPM](https://nodei.co/npm/line-circle-collision.png)](https://nodei.co/npm/line-circle-collision/)

### `collide(a, b, circle, radius[, nearest])`

Performs a collision test with the line `a-b` and the given circle. Returns true if collision occurred.

`a`, `b`, and `circle` are expected to be 2D vectors in the form of an array.

If `nearest` is passed, the nearest point found during the intersection test will be stored into that vector. This is useful if you need to find the nearest point along the line for the intersection test. If the hit returns false, you should not expect the value of `nearest` to have changed.

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md) for details.

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