Merge pull request #349 from bakedPotatoLord/drill-type
update generateProfile for drill tool types
This commit is contained in:
commit
0299f308e9
3 changed files with 85 additions and 8 deletions
|
|
@ -10,7 +10,8 @@
|
||||||
"flute_len": 2,
|
"flute_len": 2,
|
||||||
"taper_tip": 0,
|
"taper_tip": 0,
|
||||||
"metric": false
|
"metric": false
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"id": 2001,
|
"id": 2001,
|
||||||
"number": 6,
|
"number": 6,
|
||||||
"name": "ball 1/8",
|
"name": "ball 1/8",
|
||||||
|
|
@ -21,7 +22,8 @@
|
||||||
"flute_len": 2,
|
"flute_len": 2,
|
||||||
"taper_tip": 0,
|
"taper_tip": 0,
|
||||||
"metric": false
|
"metric": false
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"id": 2002,
|
"id": 2002,
|
||||||
"number": 4,
|
"number": 4,
|
||||||
"name": "ball 1/4",
|
"name": "ball 1/4",
|
||||||
|
|
@ -32,7 +34,8 @@
|
||||||
"flute_len": 2,
|
"flute_len": 2,
|
||||||
"taper_tip": 0,
|
"taper_tip": 0,
|
||||||
"metric": false
|
"metric": false
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"id": 1000,
|
"id": 1000,
|
||||||
"number": 3,
|
"number": 3,
|
||||||
"type": "endmill",
|
"type": "endmill",
|
||||||
|
|
@ -43,7 +46,8 @@
|
||||||
"flute_diam": 0.0625,
|
"flute_diam": 0.0625,
|
||||||
"flute_len": 1.5,
|
"flute_len": 1.5,
|
||||||
"taper_tip": 0
|
"taper_tip": 0
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"id": 1001,
|
"id": 1001,
|
||||||
"number": 2,
|
"number": 2,
|
||||||
"type": "endmill",
|
"type": "endmill",
|
||||||
|
|
@ -54,7 +58,8 @@
|
||||||
"flute_diam": 0.125,
|
"flute_diam": 0.125,
|
||||||
"flute_len": 1.5,
|
"flute_len": 1.5,
|
||||||
"taper_tip": 0
|
"taper_tip": 0
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"id": 1002,
|
"id": 1002,
|
||||||
"number": 1,
|
"number": 1,
|
||||||
"type": "endmill",
|
"type": "endmill",
|
||||||
|
|
@ -65,5 +70,29 @@
|
||||||
"flute_diam": 0.25,
|
"flute_diam": 0.25,
|
||||||
"flute_len": 2,
|
"flute_len": 2,
|
||||||
"taper_tip": 0
|
"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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -88,6 +88,17 @@ class Tool {
|
||||||
return this.unitScale() * this.tool.shaft_len;
|
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() {
|
shaftDiameter() {
|
||||||
return this.unitScale() * this.tool.shaft_diam;
|
return this.unitScale() * this.tool.shaft_diam;
|
||||||
}
|
}
|
||||||
|
|
@ -108,11 +119,22 @@ class Tool {
|
||||||
return this.isTaperMill();
|
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) {
|
generateProfile(resolution) {
|
||||||
// generate tool profile
|
// generate tool profile
|
||||||
let ball = this.isBallMill(),
|
let ball = this.isBallMill(),
|
||||||
taper = this.hasTaper(),
|
taper = this.hasTaper(),
|
||||||
|
drill = this.isDrill(),
|
||||||
tip_diameter = this.tipDiameter(),
|
tip_diameter = this.tipDiameter(),
|
||||||
|
drill_tip_length = this.drillTipLength(),
|
||||||
shaft_offset = this.fluteLength(),
|
shaft_offset = this.fluteLength(),
|
||||||
flute_diameter = this.fluteDiameter(),
|
flute_diameter = this.fluteDiameter(),
|
||||||
shaft_diameter = this.shaftDiameter(),
|
shaft_diameter = this.shaftDiameter(),
|
||||||
|
|
@ -139,7 +161,7 @@ class Tool {
|
||||||
let dx = x - toolCenter,
|
let dx = x - toolCenter,
|
||||||
dy = y - toolCenter,
|
dy = y - toolCenter,
|
||||||
dist_from_center = Math.sqrt(dx * dx + dy * dy);
|
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);
|
maxo = Math.max(maxo, dx, dy);
|
||||||
// flute offset points
|
// flute offset points
|
||||||
let z_offset = 0;
|
let z_offset = 0;
|
||||||
|
|
@ -147,8 +169,10 @@ class Tool {
|
||||||
let rd = dist_from_center * dist_from_center;
|
let rd = dist_from_center * dist_from_center;
|
||||||
z_offset = Math.sqrt(rpixsq - rd) * resolution - flute_radius;
|
z_offset = Math.sqrt(rpixsq - rd) * resolution - flute_radius;
|
||||||
// z_offset = (1 - Math.cos((dist_from_center / flute_radius_pix_float) * HPI)) * -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;
|
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);
|
toolOffset.push(dx, dy, z_offset);
|
||||||
} else if (shaft_offset && larger_shaft && dist_from_center <= shaft_radius_pix_float) {
|
} else if (shaft_offset && larger_shaft && dist_from_center <= shaft_radius_pix_float) {
|
||||||
|
|
|
||||||
|
|
@ -829,6 +829,30 @@ const conf = exports({
|
||||||
flute_diam: 0.125,
|
flute_diam: 0.125,
|
||||||
flute_len: 1.5,
|
flute_len: 1.5,
|
||||||
taper_tip: 0,
|
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)
|
// currently selected device (current mode)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue