MCPcopy Index your code
hub / github.com/plotly/plotly.js / triangulate1D

Function triangulate1D

stackgl_modules/index.js:9969–9995  ·  view source on GitHub ↗
(n, points, includePointAtInfinity)

Source from the content-addressed store, hash-verified

9967}
9968
9969function triangulate1D(n, points, includePointAtInfinity) {
9970 if(n === 1) {
9971 if(includePointAtInfinity) {
9972 return [ [-1, 0] ]
9973 } else {
9974 return []
9975 }
9976 }
9977 var lifted = points.map(function(p, i) {
9978 return [ p[0], i ]
9979 })
9980 lifted.sort(function(a,b) {
9981 return a[0] - b[0]
9982 })
9983 var cells = new Array(n - 1)
9984 for(var i=1; i<n; ++i) {
9985 var a = lifted[i-1]
9986 var b = lifted[i]
9987 cells[i-1] = [ a[1], b[1] ]
9988 }
9989 if(includePointAtInfinity) {
9990 cells.push(
9991 [ -1, cells[0][1], ],
9992 [ cells[n-1][1], -1 ])
9993 }
9994 return cells
9995}
9996
9997function triangulate(points, includePointAtInfinity) {
9998 var n = points.length

Callers 1

triangulateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…