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

Function barycentricCoord

stackgl_modules/index.js:16826–16846  ·  view source on GitHub ↗
(simplex, point)

Source from the content-addressed store, hash-verified

16824}
16825
16826function barycentricCoord(simplex, point) {
16827 if(simplex.length === 2) {
16828 var d0 = 0.0
16829 var d1 = 0.0
16830 for(var i=0; i<2; ++i) {
16831 d0 += Math.pow(point[i] - simplex[0][i], 2)
16832 d1 += Math.pow(point[i] - simplex[1][i], 2)
16833 }
16834 d0 = Math.sqrt(d0)
16835 d1 = Math.sqrt(d1)
16836 if(d0+d1 < 1e-6) {
16837 return [1,0]
16838 }
16839 return [d1/(d0+d1),d0/(d1+d0)]
16840 } else if(simplex.length === 3) {
16841 var closestPoint = [0,0]
16842 closestPointToTriangle(simplex[0], simplex[1], simplex[2], point, closestPoint)
16843 return barycentric(simplex, closestPoint)
16844 }
16845 return []
16846}
16847
16848function interpolate(simplex, weights) {
16849 var result = [0,0,0]

Callers 1

Calls 1

barycentricFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…