1.2.2 • Published 4 years ago

constrainodelaunato v1.2.2

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
4 years ago

Constraino Delaunato

your a wizard harry

tada

About

Based on/using delaunator as basis for delaunay triangulations, this module uses the algorithm proposed in this paper, [CONCAVE HULL: A K-NEAREST NEIGHBOURS APPROACH FOR THE COMPUTATION OF THE REGION OCCUPIED BY A SET OF POINTS], in order to create a concave hull around a point cloud.

  • Additionally, the module takes in point sets as additional optional arguments. When these are supplied, the a seperate concave boundary is created for the boundary points.
    • These points also have their own triagulation created by taking available points from the source data and clipping that area out to match the created concave boundary.

Example

  • A delaunay triangulation with a new set of points overlayed in black - the black line is to help with visibility of the points, the points are at vertices of the polygon:

  • The same set of points but with a concave boundary created around it in blue, the arrows indicate a ccw direction. (CCW from the origin (0,0) which is at the top left point of this image) The concave algorithm follows the left hand rule to determine the most suitable next point in the k grouping.
    - At this point, additional points are added along the boundary for intersections with the main triangulation. This follows a minimum distance logic, where the points are not considered for an intersection with the boundary unless one of the points perpindicular line intersects the boundary and is less than or equal to that minimum distance from that intersection. [Further Details]

  • Finally the concave boundary of the inner points are used to clip the original points into a seperate delaunay object. This object then has any triangle outside of the new concave boundary removed. It is done in this order to in order to minimize the size of the initial delaunay object and also to include the boudnary intersection points in the triangulation calculation. The new triangulation is shown overlayed in blue.

Run

For Dev - if cloned from git:

  • uses rollup for minimizing
npm install [package name]
npm start

For not dev

//ES import
import ConstrainoDelaunato as CD from 'constrainodelaunato'

//this is it, it will do the hole triangle calc on its own
let rictusempra = new CD(points, 3, holeBoundary)

// can add multiple holes
let tarantallegra = new CD(points, 3, hole1, hole2, holeN)

// hole boundaries and hole delaunay objects are stored as seperate arrays
console.log(tarantallegra.boundaries[0])
console.log(tarantallegra.boundedDelaunators[0])
  • The bounded delaunator objects for the holes are useable as delaunay objects

API

ConstrainoDelaunato

ConstrainoDelaunato

Kind: global class

new ConstrainoDelaunato(coords, k, dist)

creates a delaunator object for the larger coord point cloud, and any smalle concave boundaries and delaunator objects for holes/boundaries supplied

ParamTypeDescription
coordsArrayCoordinate cloud, can be 2D or 1D, prefer 1D of type x0, y0, x1, y1, ... xN, yN
kIntegerlower bound for point selection in k grouping - minimum possible value is 3 - you have to make a polygon
distIntegerdistance for adding points along boundary, distance between line segment perpindicular to either point of triangle segment
...boundariesArrayPoint clouds of holes in coords, stored in array boundary for concave boundaries and boundedDelaunator for created delaunator objects

constrainoDelaunato.coords2D ⇒ Array

coords2D

Kind: instance property of ConstrainoDelaunato
Returns: Array - 2D coordinate array

constrainoDelaunato.coords ⇒ Array

coords

Kind: instance property of ConstrainoDelaunato
Returns: Array - 1D coordinate array

constrainoDelaunato.triangles ⇒ Array

triangles

Kind: instance property of ConstrainoDelaunato
Returns: Array - Index array of delaunator triangles

constrainoDelaunato.hull ⇒ Array

hull

Kind: instance property of ConstrainoDelaunato
Returns: Array - Array of hull indices

constrainoDelaunato.delaunator ⇒ Object

delaunator

Kind: instance property of ConstrainoDelaunato
Returns: Object - Return delaunator object for parent points

constrainoDelaunato.boundaries ⇒ Array

boundaries

Kind: instance property of ConstrainoDelaunato
Returns: Array - concave boundary index array of parent points and hole points includes parent points as final array item

constrainoDelaunato.holes ⇒ Array

holes

Kind: instance property of ConstrainoDelaunato
Returns: Array - Delaunator object array for all hole/boundary points supplied, includes parent points as final array item

constrainoDelaunato.setTrianglesInsideBound(boundary)

setTrianglesInsideBound

Function used to clip coords to inside of boundary or hole

Kind: instance method of ConstrainoDelaunato

ParamTypeDescription
boundaryBoundaryExtraboundary extra object

constrainoDelaunato.update(point)

update

Kind: instance method of ConstrainoDelaunato

ParamTypeDescription
pointArrayx and y coord of point to add the delaunator object

Everything below is done automatically - but just in case...

BoundaryExtra

// 3 is k starting value
let b = new BoundaryExtra(points, 3)
b.addPoints(parentCoords, parentDelaunatorObject, distance)

below if for boundary object - should use boundaryExtra instead though

// for Object.boundaries 3 is k starting value
let b = new Boundary(points, 3)

//below is already done on object creation
const hull = b.findConcaveHull(k)// -> returns: sorted array of indices of x values for coord array

//subset returns the subset of coordinates from an index array
console.log(b.subset[hull])    

//other accessors
b.coords2D
b.hullCoords
b.printPoints
1.2.2

4 years ago

1.2.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.10

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago