OpenJSCAD.org
OpenJSCAD.org copied to clipboard
artifacts between rounded cuboid and extruded appendArc
There is some black magic. Arc from rounded cuboid and just arc from path with the same segments are not equal.
const jscad = require('@jscad/modeling')
const { arc, circle, ellipse, line, polygon, rectangle, roundedRectangle, square, star } = require('@jscad/modeling').primitives
const { translate } = require('@jscad/modeling').transforms
const { extrudeRectangular, extrudeLinear, extrudeRotate } = jscad.extrusions
const { path2, geom2 } = jscad.geometries
const { cube, cuboid, cylinder, cylinderElliptic, ellipsoid, geodesicSphere, roundedCuboid, roundedCylinder, sphere, torus, polyhedron } = jscad.primitives
const { union, subtract, intersect } = jscad.booleans
const main = () => {
const SEGMENTS = 64;
let path = path2.create([[0,0],[10,0]]);
path = path2.appendArc({endpoint:[0,10],radius: [10,10],segments:SEGMENTS},path);
path = path2.close(path);
geom2.fromPoints(path2.toPoints(path2.close(path)))
)
);
// return cuboid({size:[10,10,10]});
const cub = roundedCuboid({size: [40, 40, 40], roundRadius: 10, segments:SEGMENTS});
return [translate([-20,-20,0],subtract(sec,cub)),
translate([20,20,0],subtract(cub,sec))]
;
}
module.exports = { main } geom2.fromPoints(path2.toPoints(path2.close(path)))
)
);
// return cuboid({size:[10,10,10]});
const cub = roundedCuboid({size: [40, 40, 40], roundRadius: 10, segments:SEGMENTS});
return [translate([-20,-20,0],subtract(sec,cub)),
translate([20,20,0],subtract(cub,sec))]
;
}
module.exports = { main }
The result on the image
As I can find the problem is appendArc function, which generates unexpected count of segments.
This code generate arc. I expect to get 4 segments, but really there is 5
const SEGMENTS = 8;
let path = path2.create([[10,0]]);
path = path2.appendArc({endpoint:[-10,0],radius: [10,10],segments:SEGMENTS},path);
@Evgsurf Nice find! That code has been around for a long long time, so there may be some strange logic.
We still accept fixes for V2, so if you have time... how about changing the code?