diff --git a/notes.md b/notes.md index 9db6c67a..9d70e394 100644 --- a/notes.md +++ b/notes.md @@ -56,7 +56,6 @@ # CAM -* `B` fix ball mill profile * `B` climb vs conventional not fully consistent after refactor * `B` outside cutting direction in roughing mode inverted * `B` clear voids has double interior pass because wrong offset shadow used diff --git a/src/mode/cam/animate.js b/src/mode/cam/animate.js index f57c5d08..1ef1c0f2 100644 --- a/src/mode/cam/animate.js +++ b/src/mode/cam/animate.js @@ -367,11 +367,12 @@ self.kiri.loader.push(function() { } tool = new CAM.Tool({ tools }, undefined, toolnum); tool.generateProfile(rez); - const flen = tool.fluteLength() || 30; + const flen = tool.fluteLength() || 15; + const slen = tool.shaftLength() || 15; // const frad = tool.fluteDiameter() / 2; const prof = tool.profile; const { size, pix } = tool.profileDim; - const { pos, ind } = createGrid(pix, pix, {x:size, y:size, z:flen}, rez); + const { pos, ind } = createGrid(pix, pix, {x:size, y:size, z:flen+slen}, rez); const mid = Math.floor(pix/2); // deform mesh to fit tool profile for (let i=0, il=prof.length; i < il; ) { diff --git a/src/mode/cam/tool.js b/src/mode/cam/tool.js index 97de4e17..1bf40ca9 100644 --- a/src/mode/cam/tool.js +++ b/src/mode/cam/tool.js @@ -51,6 +51,10 @@ return this.unitScale() * this.tool.taper_tip; } + shaftLength() { + return this.unitScale() * this.tool.shaft_len; + } + shaftDiameter() { return this.unitScale() * this.tool.shaft_diam; } @@ -77,7 +81,8 @@ profile_pix_iter = shaft_pix_int + (1 - shaft_pix_int % 2), toolCenter = (shaft_pix_int - (shaft_pix_int % 2)) / 2, toolOffset = [], - larger_shaft = shaft_diameter - flute_diameter > 0.001; + larger_shaft = shaft_diameter - flute_diameter > 0.001, + rpixsq = flute_radius_pix_float * flute_radius_pix_float; // for each point in tool profile, check inside radius for (let x = 0; x < profile_pix_iter; x++) { @@ -90,7 +95,9 @@ // flute offset points let z_offset = 0; if (ball) { - z_offset = (1 - Math.cos((dist_from_center / flute_radius_pix_float) * HPI)) * -flute_radius; + let rd = dist_from_center * dist_from_center; + z_offset = Math.sqrt(rpixsq - rd) * resolution - flute_radius; + // z_offset = (1 - Math.cos((dist_from_center / flute_radius_pix_float) * HPI)) * -flute_radius; } else if (taper && dist_from_center >= tip_radius_pix_float) { z_offset = ((dist_from_center - tip_radius_pix_float) / tip_max_radius_offset) * -shaft_offset; }