Commit c7481008 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

flip origin

parent 110ad9cb
...@@ -240,10 +240,10 @@ function calculate_path() { ...@@ -240,10 +240,10 @@ function calculate_path() {
// //
for (var i = 1; i < mod.path[0].length; ++i) { for (var i = 1; i < mod.path[0].length; ++i) {
var ixp = mod.path[0][i-1][0] var ixp = mod.path[0][i-1][0]
var iyp = mod.path[0][i-1][1] var iyp = mod.height-1-mod.path[0][i-1][1]
var izp = 0.1*mod.path[0][i-1][2] var izp = 0.1*mod.path[0][i-1][2]
var ix = mod.path[0][i][0] var ix = mod.path[0][i][0]
var iy = mod.path[0][i][1] var iy = mod.height-1-mod.path[0][i][1]
var iz = 0.1*mod.path[0][i][2] var iz = 0.1*mod.path[0][i][2]
var line = document.createElementNS( var line = document.createElementNS(
'http://www.w3.org/2000/svg','line') 'http://www.w3.org/2000/svg','line')
...@@ -296,12 +296,22 @@ function calculate_path_worker() { ...@@ -296,12 +296,22 @@ function calculate_path_worker() {
var ystep = Math.floor(stepover*diameter*w/(mmunits*(xmax-xmin))) var ystep = Math.floor(stepover*diameter*w/(mmunits*(xmax-xmin)))
var path = [[]] var path = [[]]
// //
// construct tool offset
//
var toolsize = Math.floor(diameter*w/(mmunits*(xmax-xmin)))
var tooloffset = new Float32Array(toolsize*toolsize)
for (var x = 0; x < toolsize; ++x)
for (var y = 0; y < toolsize; ++y) {
var r = Math.sqrt((x-toolsize/2)*(x-toolsize/2)+(y-toolsize/2)*(y-toolsize/2))
tooloffset[y*toolsize+x] = 0
}
//
// loop over lines // loop over lines
// //
xstart = 0 xstart = 0
ystart = h-1 ystart = h-1
zstart = Math.floor((map[ystart*w+xstart]-zmax)*w/(xmax-xmin)) zstart = Math.floor((map[ystart*w+xstart]-zmax)*w/(xmax-xmin))
path[0].push([xstart,ystart,zstart]) path[0].push([xstart,h-1-ystart,zstart])
xcur = 1 xcur = 1
ycur = h-1 ycur = h-1
zcur = Math.floor((map[ycur*w+xcur]-zmax)*w/(xmax-xmin)) zcur = Math.floor((map[ycur*w+xcur]-zmax)*w/(xmax-xmin))
...@@ -332,7 +342,7 @@ function calculate_path_worker() { ...@@ -332,7 +342,7 @@ function calculate_path_worker() {
nznext = dznext/dnext nznext = dznext/dnext
dot = nxcur*nxnext+nycur*nynext+nzcur*nznext dot = nxcur*nxnext+nycur*nynext+nzcur*nznext
if (dot <= (1-error)) { if (dot <= (1-error)) {
path[0].push([xcur,ycur,zcur]) path[0].push([xcur,h-1-ycur,zcur])
xstart = xcur xstart = xcur
ystart = ycur ystart = ycur
zstart = zcur zstart = zcur
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment