From 22d37a9e841ff2de66faf2df2570cbe50199eb09 Mon Sep 17 00:00:00 2001 From: bakedpotatolord Date: Mon, 21 Apr 2025 10:12:22 -0600 Subject: [PATCH 1/2] update generateProfile for drill tool types --- src/kiri-mode/cam/tool.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/kiri-mode/cam/tool.js b/src/kiri-mode/cam/tool.js index 8c049ea0..4ef46085 100644 --- a/src/kiri-mode/cam/tool.js +++ b/src/kiri-mode/cam/tool.js @@ -88,6 +88,17 @@ class Tool { return this.unitScale() * this.tool.shaft_len; } + /** + * returns the length of the drill tip as a function of the flute diameter, + * given a 118 deg point angle. the result is in workspace units. + * + * @return {number} length of the drill tip. + */ + drillTipLength() { + const drillAngleRad = 140 * Math.PI / 180; + return 0.5 * this.fluteDiameter() * Math.sin(drillAngleRad); + } + shaftDiameter() { return this.unitScale() * this.tool.shaft_diam; } @@ -108,11 +119,22 @@ class Tool { return this.isTaperMill(); } + /** + * generate tool profile with resolution number of pixels. the result is a + * Float32Array stored in `this.profile` and `this.profileDim` containing + * dimensions of the profile in pixels and shared array buffer size. + * + * @param {number} resolution - number of pixels for the tool profile + * + * @return {Tool} this + */ generateProfile(resolution) { // generate tool profile let ball = this.isBallMill(), taper = this.hasTaper(), + drill = this.isDrill(), tip_diameter = this.tipDiameter(), + drill_tip_length = this.drillTipLength(), shaft_offset = this.fluteLength(), flute_diameter = this.fluteDiameter(), shaft_diameter = this.shaftDiameter(), @@ -139,7 +161,7 @@ class Tool { let dx = x - toolCenter, dy = y - toolCenter, dist_from_center = Math.sqrt(dx * dx + dy * dy); - if (dist_from_center <= flute_radius_pix_float) { + if (dist_from_center <= flute_radius_pix_float) { // if xy point inside flute radius maxo = Math.max(maxo, dx, dy); // flute offset points let z_offset = 0; @@ -147,8 +169,10 @@ class Tool { 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) { + } else if (taper && dist_from_center >= tip_radius_pix_float) {// if tapered and not in the flat tip radius z_offset = ((dist_from_center - tip_radius_pix_float) / tip_max_radius_offset) * -shaft_offset; + }else if(drill){ + z_offset = -dist_from_center /45; } toolOffset.push(dx, dy, z_offset); } else if (shaft_offset && larger_shaft && dist_from_center <= shaft_radius_pix_float) { From c91c5a6fa41ed1affe6aa2d3145bb51941482fc8 Mon Sep 17 00:00:00 2001 From: bakedpotatolord Date: Mon, 21 Apr 2025 10:27:58 -0600 Subject: [PATCH 2/2] add drills as default CAM tools --- src/cli/kiri-cam-tools.json | 41 +++++++++++++++++++++++++++++++------ src/kiri/conf.js | 24 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/cli/kiri-cam-tools.json b/src/cli/kiri-cam-tools.json index 69453d8b..234e3d1b 100644 --- a/src/cli/kiri-cam-tools.json +++ b/src/cli/kiri-cam-tools.json @@ -10,7 +10,8 @@ "flute_len": 2, "taper_tip": 0, "metric": false - }, { + }, + { "id": 2001, "number": 6, "name": "ball 1/8", @@ -21,7 +22,8 @@ "flute_len": 2, "taper_tip": 0, "metric": false - }, { + }, + { "id": 2002, "number": 4, "name": "ball 1/4", @@ -32,7 +34,8 @@ "flute_len": 2, "taper_tip": 0, "metric": false - }, { + }, + { "id": 1000, "number": 3, "type": "endmill", @@ -43,7 +46,8 @@ "flute_diam": 0.0625, "flute_len": 1.5, "taper_tip": 0 - }, { + }, + { "id": 1001, "number": 2, "type": "endmill", @@ -54,7 +58,8 @@ "flute_diam": 0.125, "flute_len": 1.5, "taper_tip": 0 - }, { + }, + { "id": 1002, "number": 1, "type": "endmill", @@ -65,5 +70,29 @@ "flute_diam": 0.25, "flute_len": 2, "taper_tip": 0 + }, + { + "id": 1005, + "number": 6, + "type": "drill", + "name": "drill 1/8", + "metric": false, + "shaft_diam": 0.125, + "shaft_len": 1, + "flute_diam": 0.125, + "flute_len": 1.5, + "taper_tip": 0 + }, + { + "id": 1006, + "number": 7, + "type": "drill", + "name": "drill 1/4", + "metric": false, + "shaft_diam": 0.25, + "shaft_len": 1, + "flute_diam": 0.25, + "flute_len": 2, + "taper_tip": 0 } -] +] \ No newline at end of file diff --git a/src/kiri/conf.js b/src/kiri/conf.js index a4dafed3..09645bf6 100644 --- a/src/kiri/conf.js +++ b/src/kiri/conf.js @@ -829,6 +829,30 @@ const conf = exports({ flute_diam: 0.125, flute_len: 1.5, taper_tip: 0, + }, + { + id: 1005, + number: 6, + type: "drill", + name: "drill 1/8", + metric: false, + shaft_diam: 0.125, + shaft_len: 1, + flute_diam: 0.125, + flute_len: 1.5, + taper_tip: 0, + }, + { + id: 1006, + number: 7, + type: "drill", + name: "drill 1/4", + metric: false, + shaft_diam: 0.25, + shaft_len: 1, + flute_diam: 0.25, + flute_len: 2, + taper_tip: 0, } ], // currently selected device (current mode)