circumcircle

1.0.0 • Public • Published

circumcircle

Fast algorithm to calculate the circumcircle of a 2D triangle.

demo

Install

npm install circumcircle

Example

const circumcircle = require('circumcircle');
 
const points = [ [0.0, -0.5], [0.5, 0.5], [-0.5, 0.5] ];
console.log(circumcircle(points));

Output:

{ x: 0, y: 0.125, r: 0.625 }

Demo

circumcircle demo

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 and Joseph O'Rourke

See Also

License

MIT, see LICENSE for details.

Package Sidebar

Install

npm i circumcircle

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

4.5 kB

Total Files

4

Last publish

Collaborators

  • brunoimbrizi