Cell

A Cell instance defines a polygon from a Voronoi diagram and its seed.

new Cell(contourPoints: Array, seed: any)
Parameters
contourPoints (Array) Array of points
seed (any)
Static Members
genarateHash(n1, n2, a)
Instance Members
isValid()
getHash()
getSeed()
getPolygon()
getArea()
intersectWithCell(anotherCell)
hasSamePolygon(otherCell, anotherCell)

CellCollection

A CellCollection stores Cell objects. It is the interface between the Voronoi diagram and the Cells/Polygons.

new CellCollection()
Instance Members
buildFromVoronoiDiagram(vd)
getCellHashes()
getCell(hash)
referenceSeed(x, y)
getReferencedSeedCell()
getStolenAreaInfo(anotherCellCollection)

ConvexPolygon

ConvexPolygon is a simple approach of a polygon, it's actually a simple approcah of what is a convex polygon and is mainly made to be used in the context of a polygon representing a cell of a Voronoi diagram. Here, a polygon is a list of 2D points that represent a convex polygon, with the list of point being no closed (= the last point is not a repetition of the first). The list of points describing a polygon can not be modified later.

new ConvexPolygon(points: Array)
Parameters
points (Array) can be an array of [ x, y ] (both being of type Number) or it can be an array of {x: Number, y: Number}. Depending on what is the source of points, both exist. Note: there is no integrity checking that the given list of point represent an actually convex polygon.
Static Members
removeDuplicateVertices(polygonPoints)
getPolygonCenter(polygonPoints)
orderPolygonPoints(polygonPoints)
Instance Members
isValid()
getArea()
getCellReplacementIntersection(anotherPolygon)
getHull()
isSame(otherPolygon)

Interpolator

The Interpolator is the API provider of natninter.

new Interpolator()
Instance Members
onProgress(cb)
cleanSeeds()
addSeed(seed)
addSeeds(seedArr)
setOutputSize(width, height)
hasAllSeedsInside()
generateMap()
getMap(m)
setMap(map)
isAtSeedPosition(i, j)
_generateSeedCells()
generateImage()

VectorTools

VectorTools is not instanciable and provide some static functions for computing things about vectors.

new VectorTools()
Static Members
crossProduct(v1, v2, normalize)
dotProduct(v1, v2)
normalize(v)
getNorm(v)
rotate(v, m)
getAnglePoints(p1, p2, p3)
vector2DCrossing(u1, u2, v1, v2)
pointToSegmentDistance(p, u1, u2)