add step angle option for lathe (perhaps determine heuristically in the future)
This commit is contained in:
parent
26b3f0a9e2
commit
47bd68ca0b
6 changed files with 36 additions and 32 deletions
|
|
@ -15,6 +15,7 @@ const { base } = root;
|
|||
const { config, util, polygons, newBounds, newPoint } = base;
|
||||
|
||||
const POLY = polygons,
|
||||
XAXIS = new THREE.Vector3(1,0,0),
|
||||
DEG2RAD = Math.PI / 180,
|
||||
clib = self.ClipperLib,
|
||||
clip = clib.Clipper,
|
||||
|
|
@ -967,6 +968,19 @@ class Polygon {
|
|||
return [this.first().key, this.last().key, this.length].join('~~');
|
||||
}
|
||||
|
||||
applyRotations() {
|
||||
for (let point of this.points) {
|
||||
if (point.a) {
|
||||
let p2 = new THREE.Vector3(point.x, point.y, point.z)
|
||||
.applyAxisAngle(XAXIS, point.a * DEG2RAD);
|
||||
point.x = p2.x;
|
||||
point.y = p2.y;
|
||||
point.z = p2.z;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set this polygon's winding in alignment with the supplied polygon
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1339,6 +1339,7 @@ CAM.init = function(kiri, api) {
|
|||
tool: 'camLatheTool',
|
||||
spindle: 'camLatheSpindle',
|
||||
step: 'camLatheOver',
|
||||
angle: 'camLatheAngle',
|
||||
rate: 'camLatheSpeed',
|
||||
tolerance: 'camTolerance',
|
||||
axis: 'X'
|
||||
|
|
@ -1349,6 +1350,7 @@ CAM.init = function(kiri, api) {
|
|||
spindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, show:hasSpindle}),
|
||||
rate: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, units:true}),
|
||||
step: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.01,10.0)}),
|
||||
angle: UC.newInput(LANG.cc_sang_s, {title:LANG.cc_sang_l, convert:UC.toFloat, bound:UC.bound(0.01,10.0)}),
|
||||
tolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0,10.0), units:true, round:4}),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -857,8 +857,8 @@ class OpLathe extends CamOp {
|
|||
let { settings } = state;
|
||||
|
||||
let { setTool, setSpindle, setPrintPoint } = ops;
|
||||
let { camOut, newLayer, polyEmit, printPoint, lastPoint } = ops;
|
||||
let { bounds, zmax } = ops;
|
||||
let { camOut, newLayer, printPoint } = ops;
|
||||
let { zmax } = ops;
|
||||
|
||||
let toolDiam = new CAM.Tool(settings, op.tool).fluteDiameter();
|
||||
let stepover = toolDiam * op.step * 2;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ class Topo4 {
|
|||
zMin = min.z + 0.0001,
|
||||
tolerance = op.tolerance,
|
||||
resolution = tolerance ? tolerance : 1 / Math.sqrt(density / (span.x * span.y)),
|
||||
step = this.step = (tool.traceOffset() * 2) * op.step;
|
||||
step = this.step = (tool.traceOffset() * 2) * op.step,
|
||||
angle = this.angle = op.angle || 1;
|
||||
|
||||
if (tolerance === 0) {
|
||||
console.log(widget.id, 'topo4 auto tolerance', resolution.round(4));
|
||||
|
|
@ -108,7 +109,7 @@ class Topo4 {
|
|||
index++;
|
||||
}
|
||||
slices.push(slice);
|
||||
console.log({ shards, range, step, slices });
|
||||
// console.log({ shards, range, step, slices });
|
||||
|
||||
if (kiri.minions.running > 1) {
|
||||
return await this.sliceMinions(onupdate);
|
||||
|
|
@ -265,11 +266,10 @@ class Topo4 {
|
|||
async latheWorker(onupdate) {
|
||||
const { sliced, tool } = this;
|
||||
|
||||
const steps = 100;
|
||||
const rota = (360 / steps) * DEG2RAD;
|
||||
const rota = this.angle * DEG2RAD;
|
||||
const steps = (Math.PI * 2) / rota;
|
||||
const axis = new THREE.Vector3(1, 0, 0);
|
||||
const mrot = new THREE.Matrix4().makeRotationAxis(axis, rota);
|
||||
|
||||
const slices = sliced.map(s => { return { z: s.z, lines: s.shared } });
|
||||
const paths = [];
|
||||
const recs = [];
|
||||
|
|
@ -295,36 +295,21 @@ class Topo4 {
|
|||
}
|
||||
|
||||
for (let rec of recs) {
|
||||
const { angle, degrees, heights } = rec;
|
||||
const points = heights.toFloat32();
|
||||
|
||||
const poly = newPolygon().setOpen().addPoints(
|
||||
[...points].group(3).map((a,i) => {
|
||||
let p = newPoint(a[0], a[1], a[2]).setA(degrees)
|
||||
paths[i].camLines[0].push(p);
|
||||
return p;
|
||||
})
|
||||
);
|
||||
rotatePoints(points, new THREE.Matrix4().makeRotationAxis(axis, angle));
|
||||
continue;
|
||||
|
||||
// const slice = newSlice();
|
||||
// slice.camLines = [ poly ];
|
||||
|
||||
// const rndr = newPolygon().setOpen().addPoints(
|
||||
// [...points].group(3).map(a => newPoint(a[0], a[1], a[2]))
|
||||
// );
|
||||
|
||||
// slice.output()
|
||||
// .setLayer("lathe", { line: 0xffff00 })
|
||||
// .addPoly(rndr);
|
||||
// paths.push(slice);
|
||||
const { degrees, heights } = rec;
|
||||
[...heights].group(3).forEach((a,i) => {
|
||||
paths[i].camLines[0].push( newPoint(a[0], a[1], a[2]).setA(degrees) );
|
||||
});
|
||||
}
|
||||
|
||||
for (let slice of paths) {
|
||||
const poly = slice.camLines[0];
|
||||
if (!poly.length) {
|
||||
continue;
|
||||
}
|
||||
slice.camLines[0].push(poly.points[0].clone());
|
||||
slice.output()
|
||||
.setLayer("lathe", { line: 0xffff00 })
|
||||
.addPoly(slice.camLines[0]);
|
||||
.addPoly(poly.clone().applyRotations());
|
||||
}
|
||||
|
||||
// console.log({ tool, slices, paths });
|
||||
|
|
|
|||
|
|
@ -505,6 +505,7 @@ const conf = exports({
|
|||
camLatheTool: 1000,
|
||||
camLatheSpindle: 1000,
|
||||
camLatheOver: 0.1,
|
||||
camLatheAngle: 1,
|
||||
camLatheSpeed: 500,
|
||||
camTolerance: 0,
|
||||
camTraceTool: 1000,
|
||||
|
|
|
|||
|
|
@ -444,6 +444,8 @@ self.kiri.lang['en-us'] = {
|
|||
cc_spnd_l: ["spindle speed in","revolutions / minute"],
|
||||
cc_sovr_s: "step over",
|
||||
cc_sovr_l: ["a fraction of tool diameter between 0 and 1. values greater than 0.49 may result in uncut areas or undesirable artifacts."],
|
||||
cc_sang_s: "step angle",
|
||||
cc_sang_l: ["rotation in degrees between lathe axial points"],
|
||||
cc_sdwn_s: "step down",
|
||||
cc_sdwn_l: ["step down depth","for each pass","in workspace units","0 to disable"],
|
||||
cc_thru_s: "cut thru",
|
||||
|
|
|
|||
Loading…
Reference in a new issue