Skip to content
Snippets Groups Projects
Commit 401a9af9 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

wip

parent 5621e00a
Branches
No related tags found
No related merge requests found
...@@ -300,10 +300,11 @@ function calculate_path_worker() { ...@@ -300,10 +300,11 @@ function calculate_path_worker() {
// //
var toolsize = Math.floor(diameter*w/(mmunits*(xmax-xmin))) var toolsize = Math.floor(diameter*w/(mmunits*(xmax-xmin)))
var tooloffset = new Float32Array(toolsize*toolsize) var tooloffset = new Float32Array(toolsize*toolsize)
var toolmiddle = Math.floor(toolsize/2)
for (var x = 0; x < toolsize; ++x) for (var x = 0; x < toolsize; ++x)
for (var y = 0; y < toolsize; ++y) { for (var y = 0; y < toolsize; ++y) {
var r = Math.sqrt((x-toolsize/2)*(x-toolsize/2)+(y-toolsize/2)*(y-toolsize/2)) var r = Math.sqrt((x-toolmiddle)*(x-toolmiddle)+(y-toolmiddle)*(y-toolmiddle))
if (r <= toolsize/2) if (r <= toolmiddle)
tooloffset[y*toolsize+x] = 0 tooloffset[y*toolsize+x] = 0
else else
tooloffset[y*toolsize+x] = Number.MAX_VALUE tooloffset[y*toolsize+x] = Number.MAX_VALUE
...@@ -311,15 +312,15 @@ function calculate_path_worker() { ...@@ -311,15 +312,15 @@ function calculate_path_worker() {
// //
// loop over lines // loop over lines
// //
xstart = 0 var xstart = 0
ystart = h-1 var ystart = h-1
zstart = Math.floor((map[ystart*w+xstart]-zmax)*w/(xmax-xmin)) var zstart = (map[ystart*w+xstart]-zmax)*w/(xmax-xmin)
path[0].push([xstart,h-1-ystart,zstart]) path[0].push([xstart,h-1-ystart,zstart])
xcur = 1 var xcur = 1
ycur = h-1 var ycur = h-1
zcur = Math.floor((map[ycur*w+xcur]-zmax)*w/(xmax-xmin)) var zcur = (map[ycur*w+xcur]-zmax)*w/(xmax-xmin)
dx = 1 var dx = 1
dy = 0 var dy = 0
while (1) { while (1) {
// //
// move to next point // move to next point
...@@ -334,9 +335,12 @@ function calculate_path_worker() { ...@@ -334,9 +335,12 @@ function calculate_path_worker() {
// //
// find offset at next point // find offset at next point
// //
for (var x = 0; x < toolsize; ++x) for (var xoffset = 0; xoffset < toolsize; ++xoffset)
for (var y = 0; y < toolsize; ++y) { for (var yoffset = 0; yoffset < toolsize; ++yoffset) {
znext = Math.floor((map[ynext*w+xnext]-zmax)*w/(xmax-xmin)) var x = xcur+(xoffset-toolmiddle)
var y = ycur+(yoffset-toolmiddle)
var offset = tooloffset[yoffset*toolsize+xoffset]
znext = (map[ynext*w+xnext]-zmax)*w/(xmax-xmin)
} }
// //
// vectorize // vectorize
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment