Skip to content

Instantly share code, notes, and snippets.

@jmbarbier
Last active October 15, 2023 06:17
Show Gist options
  • Save jmbarbier/6fe3a545b375c4b285d5850c907e662b to your computer and use it in GitHub Desktop.
Save jmbarbier/6fe3a545b375c4b285d5850c907e662b to your computer and use it in GitHub Desktop.
// Cubique faces centrées
const jscad = require('@jscad/modeling')
const {cuboid, sphere, polygon} = jscad.primitives
const {translate, rotate} = jscad.transforms
const {union, intersect} = jscad.booleans
const {colorize} = jscad.colors
const {sqrt} = Math
const {extrudeLinear} = jscad.extrusions
const {degToRad} = jscad.utils
const getParameterDefinitions = () => {
return [
{ name: 'radius', type: 'int', initial: 20, caption: 'Rayon en mm ?' },
{ name: 'recouvrement', type: 'int', initial: 10, caption: 'Recouvrement en 1/10 de mm ?' },
{ name: 'qualite', type:'int', initial: 40, caption: 'Qualité des faces ?' }
];
}
const main = (params) => {
const R = params.radius; // Rayon
const m = params.recouvrement/10; // Marge
const a = 4/sqrt(2)*R;
const sph = {radius: R+m, segments: params.qualite};
return intersect(
cuboid({size: [a,a,a], center:[a/2,a/2,a/2]}),
union(
translate([0,0,0], sphere(sph)),
translate([a,0,0], sphere(sph)),
translate([0,a,0], sphere(sph)),
translate([a,a,0], sphere(sph)),
translate([0,0,a], sphere(sph)),
translate([a,0,a], sphere(sph)),
translate([0,a,a], sphere(sph)),
translate([a,a,a], sphere(sph)),
translate([a/2, 0, a/2], sphere(sph)),
translate([0, a/2, a/2], sphere(sph)),
translate([a/2, a/2, 0], sphere(sph)),
translate([a/2, a/2, a], sphere(sph)),
translate([a/2, a, a/2], sphere(sph)),
translate([a, a/2, a/2], sphere(sph))
))
}
module.exports = {main, getParameterDefinitions }
@jmbarbier
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment