From 3eae5fcc59d40487ec9c52718ac4e0ef353ac271 Mon Sep 17 00:00:00 2001 From: Pasquale Vitiello Date: Sun, 15 Nov 2026 17:09:11 +0100 Subject: [PATCH 1/6] Add crank and piston motion study --- .../plotter/crank-piston-motion-drawing.tsx | 222 ++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 components/plotter/crank-piston-motion-drawing.tsx diff --git a/components/plotter/crank-piston-motion-drawing.tsx b/components/plotter/crank-piston-motion-drawing.tsx new file mode 100644 index 0000000..11c8a2d --- /dev/null +++ b/components/plotter/crank-piston-motion-drawing.tsx @@ -0,0 +1,222 @@ +import { useId } from "react"; +import { BlueprintDrawing } from "./blueprint-drawing"; + +// Ideal planar slider-crank construction, in SVG units. Constant crank speed +// drives a horizontal slider through a rigid rod; these are not engine specs. +const mechanism = { + centerX: 150, + centerY: 220, + crankRadius: 60, + rodLength: 198, + duration: 2.8, +} as const; + +const number = (value: number) => Number(value.toFixed(6)); +const point = (x: number, y: number) => `${number(x)} ${number(y)}`; + +function capsule( + ax: number, + ay: number, + bx: number, + by: number, + radius: number, +) { + const length = Math.hypot(bx - ax, by - ay); + const nx = (-(by - ay) / length) * radius; + const ny = ((bx - ax) / length) * radius; + return `M${point(ax + nx, ay + ny)}L${point(bx + nx, by + ny)}A${radius} ${radius} 0 0 0 ${point(bx - nx, by - ny)}L${point(ax - nx, ay - ny)}A${radius} ${radius} 0 0 0 ${point(ax + nx, ay + ny)}Z`; +} + +function crankGeometry(phase: number) { + const { centerX: cx, centerY: cy, crankRadius: r, rodLength } = mechanism; + const angle = 2 * Math.PI * phase - Math.PI / 3; + const ux = Math.cos(angle); + const uy = Math.sin(angle); + const bx = cx + r * ux; + const by = cy + r * uy; + const px = cx + r * ux + Math.sqrt(rodLength ** 2 - (r * uy) ** 2); + const nx = -uy * 5; + const ny = ux * 5; + const trim = Math.sqrt(10 ** 2 - 5 ** 2); + + return { + crankPinX: number(bx), + crankPinY: number(by), + pistonX: number(px), + piston: `M${number(px - 26)} 185H${number(px + 28)}V255H${number(px - 26)}`, + rings: `M${number(px + 14)} 185V255M${number(px + 20)} 185V255`, + crank: `M${point(cx + ux * trim + nx, cy + uy * trim + ny)}L${point(bx - ux * trim + nx, by - uy * trim + ny)}M${point(cx + ux * trim - nx, cy + uy * trim - ny)}L${point(bx - ux * trim - nx, by - uy * trim - ny)}`, + rod: capsule(bx, by, px, cy, 10), + // The rod owns the front silhouette. Subtract its footprint plus one unit + // from rear linework instead of painting a background-colored patch. + rearClip: `M0 0H560V440H0Z ${capsule(bx, by, px, cy, 11)}`, + }; +} + +// Every moving attribute follows this same linear timeline. Dense exact-state +// samples keep the rigid geometry and the occlusion boundary in lockstep. +const sampleCount = 180; +const frames = Array.from({ length: sampleCount + 1 }, (_, index) => + crankGeometry(index === sampleCount ? 0 : index / sampleCount), +); +const keyTimes = frames + .map((_, index) => Number((index / sampleCount).toFixed(9))) + .join(";"); +const initial = frames[0]; +type GeometryAttribute = keyof ReturnType; + +function CrankMotion({ + attribute, + attributeName, +}: { + attribute: GeometryAttribute; + attributeName: string; +}) { + return ( + frame[attribute]).join(";")} + /> + ); +} + +const cylinderHatch = Array.from({ length: 16 }, (_, index) => { + const x = 270 + index * 12; + return `M${x} 180l10 -10M${x} 270l10 -10`; +}).join(""); + +function CrankPistonDrawing({ animated }: { animated: boolean }) { + const clipId = `${useId()}-crank-rear-outside-rod`; + + return ( + + + + + + {animated && ( + + )} + + + + + + + + + + + + + + + + + + + {/* The open skirt lets the rod enter through the left of the piston. */} + + {animated && } + + + {animated && } + + + + + {animated && } + + + + + + + {animated && } + + + {animated && ( + <> + + + + )} + + + {animated && } + + + + + + + + + 120 + + + Stroke = 2r + + + Crank radius · 60 + + + Crank + + + Cylinder + + + Connecting rod · 198 + + + + + + + + ); +} + +export function CrankPistonStudy() { + return ; +} + +export function CrankPistonMotionDrawing() { + return ; +} From 884e7743edbf47416e1fa3de62d60dee0689bd12 Mon Sep 17 00:00:00 2001 From: Pasquale Vitiello Date: Sun, 15 Nov 2026 17:10:55 +0100 Subject: [PATCH 2/6] Add Geneva mechanism motion study --- .../geneva-mechanism-motion-drawing.tsx | 227 ++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 components/plotter/geneva-mechanism-motion-drawing.tsx diff --git a/components/plotter/geneva-mechanism-motion-drawing.tsx b/components/plotter/geneva-mechanism-motion-drawing.tsx new file mode 100644 index 0000000..634cad1 --- /dev/null +++ b/components/plotter/geneva-mechanism-motion-drawing.tsx @@ -0,0 +1,227 @@ +import { useId } from "react"; +import { BlueprintDrawing } from "./blueprint-drawing"; + +// Geometric indexing schematic: the pin advances one radial slot per input +// turn. Locking hardware is omitted; the wheel holds its exit angle in dwell. +const geneva = { + driver: { x: 166, y: 218 }, + wheel: { x: 322, y: 218 }, + centerDistance: 156, + inputPeriod: 4, + cycle: 16, + outerRadius: 116, + scallopRadius: 84, + slotHalfWidth: 7, + slotBottom: 35, + lipRadius: 4, + cornerRadius: 4, +} as const; +const crankRadius = geneva.centerDistance / Math.SQRT2; +const number = (value: number) => Number(value.toFixed(5)); + +function wheelPoint(x: number, y: number, angle: number) { + return `${number(geneva.wheel.x + x * Math.cos(angle) - y * Math.sin(angle))} ${number(geneva.wheel.y + x * Math.sin(angle) + y * Math.cos(angle))}`; +} + +// Each slot mouth meets a short outer circular arc through a tangent fillet. +// A second tangent fillet joins that arc to the concave circular scallop. +function wheelOutline() { + const { + outerRadius: outer, + scallopRadius: scallop, + slotHalfWidth: halfWidth, + slotBottom: bottom, + lipRadius: lip, + cornerRadius: corner, + centerDistance, + } = geneva; + const lipCenter = [ + Math.sqrt((outer - lip) ** 2 - (halfWidth + lip) ** 2), + halfWidth + lip, + ]; + const mouth = lipCenter.map((value) => (value * outer) / (outer - lip)); + const filletOrbit = outer - corner; + const scallopOffset = scallop + corner; + const along = + (filletOrbit ** 2 + centerDistance ** 2 - scallopOffset ** 2) / + (2 * centerDistance); + const across = Math.sqrt(filletOrbit ** 2 - along ** 2); + const filletCenter = [ + (along + across) / Math.SQRT2, + (along - across) / Math.SQRT2, + ]; + const outerJoin = filletCenter.map((value) => (value * outer) / filletOrbit); + const scallopJoin = filletCenter.map( + (value) => crankRadius + ((value - crankRadius) * scallop) / scallopOffset, + ); + + let path = `M${wheelPoint(mouth[0], -mouth[1], 0)}`; + for (let index = 0; index < 4; index++) { + const angle = (index * Math.PI) / 2; + path += `A${lip} ${lip} 0 0 1 ${wheelPoint(lipCenter[0], -halfWidth, angle)}`; + path += `L${wheelPoint(bottom, -halfWidth, angle)}A${halfWidth} ${halfWidth} 0 0 0 ${wheelPoint(bottom, halfWidth, angle)}`; + path += `L${wheelPoint(lipCenter[0], halfWidth, angle)}A${lip} ${lip} 0 0 1 ${wheelPoint(mouth[0], mouth[1], angle)}`; + path += `A${outer} ${outer} 0 0 1 ${wheelPoint(outerJoin[0], outerJoin[1], angle)}`; + path += `A${corner} ${corner} 0 0 1 ${wheelPoint(scallopJoin[0], scallopJoin[1], angle)}`; + path += `A${scallop} ${scallop} 0 0 0 ${wheelPoint(scallopJoin[1], scallopJoin[0], angle)}`; + path += `A${corner} ${corner} 0 0 1 ${wheelPoint(outerJoin[1], outerJoin[0], angle)}`; + path += `A${outer} ${outer} 0 0 1 ${wheelPoint(mouth[1], mouth[0], angle)}`; + } + return `${path}Z`; +} + +const outline = wheelOutline(); +const outsideWheel = `M-1000 -1000H1000V1000H-1000Z ${outline}`; +const outputPivot = `${geneva.wheel.x} ${geneva.wheel.y}`; +const inputPivot = `${geneva.driver.x} ${geneva.driver.y}`; + +// The exact pin constraint is sampled at 120 Hz during the one-second index. +// Explicit dwell endpoints preserve the three-second hold without extra frames. +// Four quarter turns return the orientation mark to the same pose at the seam. +const frames = Array.from({ length: 4 }, (_, turn) => { + const samples = 120; + const active = Array.from({ length: samples + 1 }, (_, sample) => { + const progress = sample / samples; + const inputAngle = -Math.PI / 4 + (progress * Math.PI) / 2; + const outputAngle = -Math.atan2( + crankRadius * Math.sin(inputAngle), + geneva.centerDistance - crankRadius * Math.cos(inputAngle), + ); + return { + time: turn * geneva.inputPeriod + progress, + rotation: (outputAngle * 180) / Math.PI - turn * 90, + }; + }); + return [ + ...active.slice(turn === 0 ? 0 : 1), + { time: (turn + 1) * geneva.inputPeriod, rotation: -45 - turn * 90 }, + ]; +}).flat(); +const keyTimes = frames + .map((frame) => Number((frame.time / geneva.cycle).toFixed(9))) + .join(";"); +const outputValues = frames + .map((frame) => `${number(frame.rotation)} ${outputPivot}`) + .join(";"); + +function OutputMotion() { + return ( + + ); +} + +function GenevaDrawing({ animated }: { animated: boolean }) { + const clipId = `${useId()}-geneva-orbit-outside-wheel`; + + return ( + + + + + + {animated && } + + + + + + + + + + + + + + + + {animated && } + + + + + + {animated && ( + + )} + + + + + + + + + + {geneva.centerDistance} + + + Driver + + + Four slots + + + 360° input · 90° output + + + + + ); +} + +export function GenevaMechanismStudy() { + return ; +} + +export function GenevaMechanismMotionDrawing() { + return ; +} From c65f5737639980afbdac72141fe6db35cf7c03e2 Mon Sep 17 00:00:00 2001 From: Pasquale Vitiello Date: Sun, 15 Nov 2026 17:12:14 +0100 Subject: [PATCH 3/6] Pause engineering animations while the page is hidden Added syncPlayback function to manage SVG animations based on visibility and motion preferences. --- components/plotter/engineering-motion-preview.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/plotter/engineering-motion-preview.tsx b/components/plotter/engineering-motion-preview.tsx index 6f52325..238a611 100644 --- a/components/plotter/engineering-motion-preview.tsx +++ b/components/plotter/engineering-motion-preview.tsx @@ -28,8 +28,13 @@ export function EngineeringMotionPreview({ useEffect(() => { const svg = animation.current?.querySelector("svg"); if (!svg) return; - if (reducedMotion || !inView) svg.pauseAnimations(); - else svg.unpauseAnimations(); + const syncPlayback = () => { + if (reducedMotion || !inView || document.hidden) svg.pauseAnimations(); + else svg.unpauseAnimations(); + }; + syncPlayback(); + document.addEventListener("visibilitychange", syncPlayback); + return () => document.removeEventListener("visibilitychange", syncPlayback); }, [reducedMotion, inView]); return ( From 26f033eb82f949b7c2032f54664ebd8eff16d148 Mon Sep 17 00:00:00 2001 From: Pasquale Vitiello Date: Sun, 15 Nov 2026 17:14:59 +0100 Subject: [PATCH 4/6] Keep mechanical annotations readable on compact screens Added responsive styles for drawing elements based on container size and reduced motion preference. --- .../engineering-motion-preview.module.css | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/components/plotter/engineering-motion-preview.module.css b/components/plotter/engineering-motion-preview.module.css index 3a33eea..92b1bec 100644 --- a/components/plotter/engineering-motion-preview.module.css +++ b/components/plotter/engineering-motion-preview.module.css @@ -1,7 +1,23 @@ +.drawing { + container-type: inline-size; +} + .animation { display: none; } +@container (max-width: 559px) { + .drawing [data-mechanical-study] text, + .drawing [data-mechanical-study] [data-plotter-role="dimension"], + .drawing [data-mechanical-study] [data-plotter-role="leader"] { + display: none; + } + + .drawing [data-mechanical-study] * { + vector-effect: non-scaling-stroke; + } +} + @media (prefers-reduced-motion: no-preference) { .drawing[data-live] .animation { display: block; From fee61acde9d5e1e2c9d118153903b23063373f30 Mon Sep 17 00:00:00 2001 From: Pasquale Vitiello Date: Sun, 15 Nov 2026 17:15:45 +0100 Subject: [PATCH 5/6] Add Geneva and crank piston to the animation gallery --- app/animations/page.tsx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/animations/page.tsx b/app/animations/page.tsx index ac2e68b..92a7510 100644 --- a/app/animations/page.tsx +++ b/app/animations/page.tsx @@ -1,10 +1,18 @@ import type { Metadata } from "next"; import type { ReactNode } from "react"; +import { + CrankPistonMotionDrawing, + CrankPistonStudy, +} from "@/components/plotter/crank-piston-motion-drawing"; import { EngineeringMotionPreview } from "@/components/plotter/engineering-motion-preview"; import { NewtonsCradleStudy, ProductionChainStudy, } from "@/components/plotter/engineering-studies"; +import { + GenevaMechanismMotionDrawing, + GenevaMechanismStudy, +} from "@/components/plotter/geneva-mechanism-motion-drawing"; import { illustrations } from "@/components/plotter/illustrations"; import { IrisApertureMotionDrawing } from "@/components/plotter/iris-aperture-motion-drawing"; import { NewtonsCradleMotionDrawing } from "@/components/plotter/newtons-cradle-motion-drawing"; @@ -101,6 +109,30 @@ const studies: { ), }, + { + id: "geneva-mechanism-animation", + label: "Motion only", + title: "Geneva mechanism", + description: + "A rotating pin enters one of four slots, advances the wheel by a quarter-turn, and releases it into a rest before the next step.", + preview: ( + }> + + + ), + }, + { + id: "crank-piston-animation", + label: "Motion only", + title: "Crank and piston", + description: + "Continuous rotation becomes a back-and-forth stroke. The connecting rod keeps its length while the piston follows a fixed horizontal axis.", + preview: ( + }> + + + ), + }, { id: "orbits-animation", label: "Motion only", From 704907ce951286efa50b575d64551c0ed627d142 Mon Sep 17 00:00:00 2001 From: Pasquale Vitiello Date: Sun, 15 Nov 2026 17:16:31 +0100 Subject: [PATCH 6/6] Document mechanical animation component ownership --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 36828a5..a83884f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,6 +62,7 @@ The installed skill does not depend on the website. These paths are relative to | Static MEC-05 and OBJ-05 | `components/plotter/engineering-studies.tsx` | | MEC-05 shared core hatching | `components/plotter/production-chain-hatching.tsx` | | MEC-05 and OBJ-05 timelines | `components/plotter/production-chain-motion-drawing.tsx`, `components/plotter/newtons-cradle-motion-drawing.tsx` | +| Geneva and crank/piston stills and timelines | `components/plotter/geneva-mechanism-motion-drawing.tsx`, `components/plotter/crank-piston-motion-drawing.tsx` | | Engineering playback, fallback, and visibility | `components/plotter/engineering-motion-preview.tsx` | | Resolved pilot export adapter | `scripts/export-plotter-pilots.tsx` | | Download artifact generator | `scripts/build-plotter-downloads.tsx` |