Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brunoimbrizi/circumcircle
Fast algorithm to calculate the circumcircle of a triangle
https://github.com/brunoimbrizi/circumcircle
Last synced: 17 days ago
JSON representation
Fast algorithm to calculate the circumcircle of a triangle
- Host: GitHub
- URL: https://github.com/brunoimbrizi/circumcircle
- Owner: brunoimbrizi
- License: mit
- Created: 2020-11-10T18:17:48.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-10T18:29:55.000Z (about 4 years ago)
- Last Synced: 2024-10-10T21:42:52.322Z (about 1 month ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
circumcircle
============Fast algorithm to calculate the circumcircle of a 2D triangle.
[![demo](https://user-images.githubusercontent.com/880280/98715483-23e71700-2382-11eb-9026-65e09b46ff50.png)](https://brunoimbrizi.github.io/circumcircle/demo/index.html)
## Install
```
npm install circumcircle
```## Example
```js
const circumcircle = require('circumcircle');const points = [ [0.0, -0.5], [0.5, 0.5], [-0.5, 0.5] ];
console.log(circumcircle(points));
```
Output:```js
{ x: 0, y: 0.125, r: 0.625 }
```## Demo
[circumcircle demo](https://brunoimbrizi.github.io/circumcircle/demo/index.html)
## Usage
### `circumcircle(points, radiusSq = false)`
- `points` an array with 3 points `[ [x,y], [x,y], [x,y] ]`
- `radiusSq` returns the radius squared - faster because it skips `Math.sqrt()`
**Returns** an object with circumcenter and circumradius `{ x, y, r }`
## Credits
[Lingjia Liu](https://gist.github.com/mutoo/5617691) and [Joseph O'Rourke](https://web.archive.org/web/20071030134248/http://www.exaflop.org/docs/cgafaq/cga1.html)
## See Also
- [circumradius](https://github.com/mikolalysenko/circumradius)
- [circumcenter](https://github.com/mikolalysenko/circumcenter)## License
MIT, see [LICENSE](LICENSE) for details.