Merge pull request #349 from bakedPotatoLord/drill-type

update generateProfile for drill tool types
This commit is contained in:
Stewart Allen 2025-04-21 09:32:15 -07:00 • committed by GitHub
commit 0299f308e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 85 additions and 8 deletions

View file

@ -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
}
]
]

View file

@ -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) {

View file

@ -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)