Last active
October 15, 2023 06:21
-
-
Save jmbarbier/79e191fdbe11c4c72f39c80185eb70c7 to your computer and use it in GitHub Desktop.
Cubique centré jscad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cubique centré | |
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(3)*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, a/2, a/2], sphere(sph)) | |
)) | |
} | |
module.exports = {main, getParameterDefinitions } |
Author
jmbarbier
commented
Aug 26, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment