Skip to content

Parametric hinge

A two-leaf hinge with interlocked barrel knuckles — ready to slice and print in a single pass (print-in-place) or cut from sheet material.

Each leaf is a flat rectangular plate. Along the inner edge, alternating cylindrical knuckles are attached, centred on the barrel axis. The two leaves share the same barrel axis but have offset knuckle positions along the barrel, so they interlock: leaf A fills the gaps in leaf B and vice-versa. Each leaf also has matching cylindrical cutouts where the opposing knuckles sit, keeping the two halves free to rotate.

A pin hole runs the full length of the barrel. For print-in-place use, set Clearance to 0.25–0.4 mm so the knuckles are loose enough to rotate after printing without any post-processing.

Parameter Effect
Leaf width Width of each flat plate (hinge open = 2× this)
Leaf length Length of the hinge along the barrel axis
Leaf thickness Thickness of the flat plate
Knuckle radius Outer radius of the barrel cylinders
Pin radius Radius of the central pin hole
Knuckle count Total number of knuckles (odd → leaf A gets one more)
Clearance Gap between interlocked knuckles (print-in-place tolerance)
"use strict";
const jscad = require('@jscad/modeling');
const { cylinder, cuboid } = jscad.primitives;
const { union, subtract } = jscad.booleans;
const { translate, rotateX, rotateY } = jscad.transforms;
const { colorize } = jscad.colors;
const getParameterDefinitions = () => [
{ name: 'leafWidth', type: 'number', widget: 'slider', caption: 'Leaf width (mm)', default: 30, min: 10, max: 80, step: 1 },
{ name: 'leafLength', type: 'number', widget: 'slider', caption: 'Leaf length (mm)', default: 60, min: 20, max: 150, step: 1 },
{ name: 'leafThickness', type: 'number', widget: 'slider', caption: 'Leaf thickness (mm)', default: 3, min: 1, max: 8, step: 0.5 },
{ name: 'knuckleRadius', type: 'number', widget: 'slider', caption: 'Knuckle radius (mm)', default: 4, min: 2, max: 12, step: 0.5 },
{ name: 'pinRadius', type: 'number', widget: 'slider', caption: 'Pin hole radius (mm)', default: 1.5, min: 0.5, max: 5, step: 0.25 },
{ name: 'knuckleCount', type: 'number', widget: 'slider', caption: 'Knuckle count', default: 5, min: 3, max: 11, step: 2 },
{ name: 'clearance', type: 'number', widget: 'slider', caption: 'Clearance (mm)', default: 0.3, min: 0, max: 1, step: 0.05 },
{ name: 'renderAngle', type: 'number', widget: 'slider', caption: 'Open angle (°)', default: 0, min: 0, max: 180, step: 1 },
];
function main(params) {
const { leafWidth, leafLength, leafThickness, knuckleRadius, pinRadius, knuckleCount, clearance, renderAngle } = params;
// The barrel runs along the X axis. Each leaf is a flat plate extending
// in ±Y from the barrel, lying in the XY plane (thin in Z).
const knuckleLen = leafLength / knuckleCount;
// Build one leaf: flat plate in ±Y direction + its interlocked knuckles.
// startIndex – first knuckle index belonging to this leaf (0 = even, 1 = odd)
// ySign – +1 leaf extends in +Y, -1 extends in −Y
function buildLeaf(startIndex, ySign) {
// Plate: leafLength along X, leafWidth along Y, leafThickness along Z
const plate = cuboid({ size: [leafLength, leafWidth, leafThickness] });
const plateShifted = translate([0, ySign * leafWidth / 2, 0], plate);
// Knuckles – cylinder axis along X (rotateY 90° converts Z-cylinder → X-cylinder)
// Each knuckle centre is positioned along X at the appropriate slot.
const knuckles = [];
for (let i = startIndex; i < knuckleCount; i += 2) {
const cx = -leafLength / 2 + knuckleLen * (i + 0.5);
knuckles.push(
translate([cx, 0, 0],
rotateY(Math.PI / 2,
cylinder({ radius: knuckleRadius, height: knuckleLen - clearance, segments: 32 }),
),
),
);
}
// Cutouts – remove material from the plate at every slot occupied by the
// opposing leaf's knuckles, so the two leaves are not fused when printed.
// Radius is enlarged by clearance to leave a small radial gap.
const opposingStart = startIndex === 0 ? 1 : 0;
const cutouts = [];
for (let i = opposingStart; i < knuckleCount; i += 2) {
const cx = -leafLength / 2 + knuckleLen * (i + 0.5);
cutouts.push(
translate([cx, 0, 0],
rotateY(Math.PI / 2,
cylinder({ radius: knuckleRadius + clearance, height: knuckleLen, segments: 32 }),
),
),
);
}
// Pin hole – full-length X-axis cylinder bored through the entire barrel
const pinHole = rotateY(Math.PI / 2,
cylinder({ radius: pinRadius, height: leafLength + 1, segments: 24 }),
);
return subtract(union(plateShifted, ...knuckles), pinHole, ...cutouts);
}
// Leaf A occupies even-indexed knuckle slots and extends in −Y
const leafA = buildLeaf(0, -1);
// Leaf B occupies odd-indexed knuckle slots and extends in +Y.
// Rotate it about the barrel (X) axis to simulate the hinge opening.
const leafBBuilt = buildLeaf(1, +1);
const leafB = rotateX(renderAngle * Math.PI / 180, leafBBuilt);
return [
colorize([0.204, 0.596, 0.859], leafA), // blue
colorize([0.925, 0.412, 0.235], leafB), // orange-red
];
}
module.exports = { main, getParameterDefinitions };