Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

RunKit + npm: cube-mesh

var fuseVertices = require("fuse-vertices") , disjointUnion = require("simplicial-disjoint-union") , gridMesh = require("grid-mesh") , dup = require("dup") var resolution=[100,100,100] var scale=[1,1,1] var positions = [] , cells = [] , o = [0,0,0] , dx = [0,0,0] , dy = [0,0,0] , i, j, k, side , u, v for(i=0; i<3; ++i) { for(j=0; j<3; ++j) { o[j] = dx[j] = dy[j] = 0 } u = (i+1)%3 v = (i+2)%3 o[i] = -scale[i] / 2.0 o[u] = -scale[u] / 2.0 o[v] = -scale[v] / 2.0 dx[u] = scale[u] / resolution[u] dy[v] = scale[v] / resolution[v] console.log(resolution) for(j=0; j<2; ++j) { side = gridMesh(resolution[u], resolution[v], o, dx, dy) cells = disjointUnion(cells, side.cells, positions.length) positions = positions.concat(side.positions) for(k=0; k<3; ++k) { o[k] = -o[k] dx[k] = -dx[k] dy[k] = -dy[k] } } } console.log(positions, cells)
Created from: https://runkit.com/npm/cube-mesh
Loading…

no comments

    sign in to comment