Skip to content

Rubber Foot on a Chassis (cutaway) ​

Rubber Foot on a Chassis (cutaway), rendered in the brepjs playground
Mechanical · 151 lines▶ Run it in the playground

A recessed rubber foot with a moulded-in steel washer, held to a chassis corner by an M4 screw, in cutaway. The foot diameter, height, recess and hole, and the M4 screw, nut and washer are published figures. The kernel measures the rubber volume. The taper, the washer in the rubber, the tread rings and the chassis are a display model.

Code ​

This is the full program. The playground runs it in your browser without a change.

ts
import { clone, compound, cut, cutAll, cylinder, extrude, face, intersect, line, loft, measureVolume, polygon, revolve, rotate, threePointArc, translate, unwrap, wire } from 'brepjs/quick';
import { color } from 'brepjs/playground';

// Recessed rubber foot with a moulded-in steel washer, screwed to the corner of a chassis. The units are millimetres.
// The chassis is upside down, as on the bench when the foot goes on: the floor side of the foot points up.
// The foot sizes and the M4 hardware are published figures. The taper, the washer, the tread and the chassis are a display model.
interface FootParams {
  cutaway?: number; // degrees of the rubber, the washer and the panel to cut away (0 = whole foot)
  explode?: number; // 0 = assembled, 1 = the screw, the foot and the nut move apart along the screw
}

type P2 = [number, number]; // [r, z]
type P3 = [number, number, number];
type Step = P2 | { via: P2; to: P2 }; // a line to a point, or an arc through via
type Shape = ReturnType<typeof cylinder>;

// Kernel shapes live in WASM memory. Every temporary goes through own(). freeing() runs a build and then frees them all.
const owned: { delete(): void }[] = [];
const own = <T extends { delete(): void }>(s: T): T => {
  owned.push(s);
  return s;
};
const freeing = <T,>(build: () => T): T => { try { return build(); } finally { owned.splice(0).forEach((s) => s.delete()); } }; // also when the build throws

// ---- published figures
const FOOT = { diameter: 25.4, height: 12.7, recess: 10, recessDepth: 4.6, hole: 4.7 }; // 1 in x 0.5 in recessed bumper
const SCREW = { thread: 4, minor: 3.242, pitch: 0.7, head: 8, headHeight: 3.1, length: 16 }; // M4 coarse thread, right hand, pan head screw
const NUT = { flats: 7, height: 3.2 }; // M4 hexagon nut
const WASHER = { inner: 4.3, outer: 9, height: 0.8 }; // M4 plain washer

// ---- display model
const TAPER = 10; // degrees of the side wall
const RISE = { screw: 28, nut: -12 }; // travel along the axis at explode = 1
const PLAY = 0.06; // radial play between the screw thread and the nut thread
const INSERT = { outer: 12.5, height: 1 }; // washer in the rubber, under the screw head
const TREAD = { depth: 0.4, rings: [[8.4, 7.9], [7, 6.5]] };
const PANEL = { height: 1.5, wall: 9, hole: 4.5 };

const Z: P3 = [0, 0, 1];
// A closed outline in the (r, z) half-plane, revolved about the axis.
const lathe = (steps: Step[], angle = 2 * Math.PI): Shape => {
  const at = ([r, z]: P2): P3 => [r, 0, z];
  const ends = steps.map((s) => (Array.isArray(s) ? s : s.to));
  const edges = steps.map((s, i) => {
    const from = ends[(i + steps.length - 1) % steps.length]!;
    return own(Array.isArray(s) ? line(at(from), at(s)) : threePointArc(at(from), at(s.via), at(s.to)));
  });
  const profile = own(unwrap(face(own(unwrap(wire(edges))) as never)));
  return unwrap(revolve(profile, { axis: Z, angle })) as Shape;
};
const block = (x0: number, x1: number, y0: number, y1: number, z0: number, z1: number): Shape =>
  own(unwrap(extrude(own(unwrap(polygon([[x0, y0, z0], [x1, y0, z0], [x1, y1, z0], [x0, y1, z0]]))), [0, 0, z1 - z0])) as Shape);
// One helical thread tooth about +Z, from z = from to z = to. Its crest passes the +X side at z = ref.
// tip > core is the thread on a core of the radius core. tip < core is the thread in a bore of the radius core.
const FACETS = 12; // sections of the loft in each turn
const helixTooth = (core: number, tip: number, pitch: number, from: number, to: number, ref: number): Shape => {
  const slack = 0.998; // keeps the tooth a hair clear of its core or its bore
  const root = tip > core ? core / slack : core;
  const crest = tip > core ? tip : tip / slack;
  const half = 0.42 * pitch; // half width of the tooth at its root
  const n = Math.max(2, Math.round(((to - from) / pitch) * FACETS));
  const sections = Array.from({ length: n + 1 }, (_, j) => {
    const z = from + ((to - from) * j) / n;
    const a = 2 * Math.PI * ((z - ref) / pitch);
    const at = (r: number, dz: number): [number, number, number] => [r * Math.cos(a), r * Math.sin(a), z + dz];
    const pts = [at(root, -half), at(crest, 0), at(root, half)];
    return own(unwrap(wire(pts.map((p, i) => own(line(p, pts[(i + 1) % 3]!))))));
  });
  return unwrap(loft(sections, { ruled: false })) as Shape; // a smooth loft: one helical face for each flank
};
const volume = (s: Shape): number => unwrap(measureVolume(s));

function foot({ cutaway = 120, explode = 0 }: FootParams = {}) {
  const H = FOOT.height;
  const R0 = FOOT.diameter / 2;
  const rh = FOOT.hole / 2;
  const rr = FOOT.recess / 2;
  const floor = H - FOOT.recessDepth;
  const slope = Math.tan((TAPER * Math.PI) / 180);
  const q = Math.SQRT1_2;

  // Rubber: a tapered body with round rims, tread rings, the recess, and a pocket that holds the washer.
  const rim = 1.5;
  const rx = R0 - (H - rim) * slope - rim; // centre of the top rim arc
  const tread = TREAD.rings.flatMap(([a, b]): P2[] => [[a!, H], [a!, H - TREAD.depth], [b!, H - TREAD.depth], [b!, H]]);
  const rubber = own(lathe([
    [rh, 0], [R0 - 0.6, 0], { via: [R0 - 0.6 + 0.6 * q, 0.6 - 0.6 * q], to: [R0, 0.6] }, [rx + rim, H - rim], { via: [rx + rim * q, H - rim + rim * q], to: [rx, H] },
    ...tread, [rr + 0.4, H], [rr, H - 0.4], [rr, floor], [INSERT.outer / 2, floor], [INSERT.outer / 2, floor - INSERT.height], [rh, floor - INSERT.height],
  ]));
  const insert = own(lathe([[rh, floor - INSERT.height], [INSERT.outer / 2, floor - INSERT.height], [INSERT.outer / 2, floor], [rh, floor]]));

  // Screw: a pan head with a cross recess, and one helical tooth on the core from the chamfered end to the head.
  const rc = SCREW.thread / 2;
  const rm = SCREW.minor / 2;
  const edge = 0.42 * SCREW.pitch; // a tooth ends this far from the end of its thread
  const tip = floor - SCREW.length;
  const rk = SCREW.head / 2;
  const blank = own(lathe([
    [0, tip], [rm - 0.4, tip], [rm, tip + 0.4], [rm, floor], [rk, floor], [rk, floor + 1.5],
    { via: [rk * 0.72, floor + SCREW.headHeight - 0.45], to: [0, floor + SCREW.headHeight] },
  ]));
  const slot = block(-2.4, 2.4, -0.45, 0.45, floor + SCREW.headHeight - 1.5, floor + SCREW.headHeight + 1);
  const headed = own(unwrap(cutAll(blank, [slot, own(rotate(slot, 90, { axis: Z }) as Shape)])) as Shape);
  const screw = own(compound([headed, own(helixTooth(rm, rc, SCREW.pitch, tip + 0.4 + edge, floor - edge, 0))]) as Shape);

  // Nut and plain washer under the panel.
  const zp = -PANEL.height;
  const zn = zp - WASHER.height;
  const corner = NUT.flats / Math.sqrt(3) + 0.05;
  const hex = Array.from({ length: 6 }, (_, i): P3 => [corner * Math.cos((i * Math.PI) / 3), corner * Math.sin((i * Math.PI) / 3), zn - NUT.height]);
  const prism = own(unwrap(extrude(own(unwrap(polygon(hex))), [0, 0, NUT.height])) as Shape);
  const drop = (corner - 0.46 * NUT.flats) * Math.tan(Math.PI / 6);
  const tap = rc + PLAY; // the nut is bored to the major diameter and carries the mating tooth, half a pitch from the screw's
  const cone = own(lathe([[tap, zn - NUT.height], [0.46 * NUT.flats, zn - NUT.height], [corner, zn - NUT.height + drop], [corner, zn - drop], [0.46 * NUT.flats, zn], [tap, zn]]));
  const nut = own(compound([own(unwrap(intersect(prism, cone)) as Shape), own(helixTooth(tap, rm + PLAY, SCREW.pitch, zn - NUT.height + edge, zn - edge, SCREW.pitch / 2))]) as Shape);
  const washer = own(lathe([[WASHER.inner / 2, zn], [WASHER.outer / 2, zn], [WASHER.outer / 2, zp], [WASHER.inner / 2, zp]]));

  // Chassis corner: a panel with two walls, and the screw hole.
  const [x0, x1, y0, y1] = [-20, 18, -18, 20];
  const shell = block(x0, x1, y0, y1, -PANEL.wall, 0);
  const inside = block(x0 + PANEL.height, x1 + 1, y0 - 1, y1 - PANEL.height, -PANEL.wall - 1, zp);
  const panel = own(unwrap(cutAll(shell, [inside, own(cylinder(PANEL.hole / 2, PANEL.height + 2, { at: [0, 0, zp - 1] }))])) as Shape);

  const cm3 = volume(rubber) / 1000;

  // Cutaway: a wedge centred on +X, a little wider than the foot.
  const sweep = (Math.max(cutaway, 1) * Math.PI) / 180;
  const wedge = own(rotate(own(lathe([[0, zp - 1], [R0 + 1.5, zp - 1], [R0 + 1.5, H + 1], [0, H + 1]], sweep)), -cutaway / 2, { axis: Z }) as Shape);
  const open = (s: Shape): Shape => (cutaway > 0 ? own(unwrap(cut(s, wedge)) as Shape) : s);
  // Explode: every part moves along the screw axis. The panel stays.
  // The screw leaves the nut by one turn for each pitch of the distance between them.
  const e = Math.min(1, Math.max(0, explode));
  const lift = (s: Shape, by: number): Shape => (e > 0 ? (translate(s, [0, 0, by * e]) as Shape) : (unwrap(clone(s)) as Shape));
  const turned = own(rotate(screw, (360 * (RISE.screw - RISE.nut) * e) / SCREW.pitch, { axis: Z }) as Shape);

  return {
    rubber: lift(open(rubber), 10), insert: lift(open(insert), 10), screw: lift(turned, RISE.screw), panel: lift(open(panel), 0), washer: lift(washer, -6), nut: lift(nut, RISE.nut), cm3,
  };
}

const part = freeing(() => foot());
console.log('Rubber: ' + part.cm3.toFixed(2) + ' cm3 by the kernel. The data sheet gives no volume or mass to compare.');

export default [
  color(part.rubber, '#12b5b0'),
  color(part.insert, '#c3c9d1'),
  color(part.screw, '#a9b1ba'),
  color(part.washer, '#c3c9d1'),
  color(part.nut, '#8d96a0'),
  color(part.panel, '#f5f2ea'),
];

Functions used ​

clone compound cut cutAll cylinder extrude face intersect line loft measureVolume polygon revolve rotate threePointArc translate unwrap wire color

▶ Run Rubber Foot on a Chassis (cutaway) in the playground

Released under the Apache 2.0 License.