Skip to content

mattdesl/triangle-centroid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

triangle-centroid

stable

Computes the centroid or "center of gravity" of a triangle. The vectors can be 2D, 3D or n-dimensional.

Example

var centroid = require('triangle-centroid')

var tri = [
  [10, 0, -4],
  [20, 2, 24],
  [30, 1, 4]
]

centroid(tri)
// -> [20, 1, 8]

Usage

NPM

centroid = triangleCentroid(triangle)

For the given triangle, an array of 3 vectors, computes the centroid or "center of gravity".

Returns a new vector with the same dimension as the first point in triangle.

See Also

License

MIT, see LICENSE.md for details.

About

computes the centroid of a triangle

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published