geogebra_draw_mechanism
Create animated mechanical linkages from JSON design: execute commands, apply styles, animate, and save as .ggb and .png.
Instructions
Create a complete mechanism: new construction → commands → styles → save .ggb + PNG. Use geogebra_batch for commands instead of this tool unless you need one-step save.
── MECHANISM TEMPLATES ──
Crank-Rocker (曲柄摇杆): O1=(0,0) O2=(d,0) α=angle° crank_len=r coupler_len=L rocker_len=R A = O1 + (rcos(α), rsin(α)) c1 = Circle(A, L) c2 = Circle(O2, R) B = Intersect(c1, c2, 1) Segment(O1, A) Segment(A, B) Segment(B, O2) Animate: StartAnimation(α) Style: thick segments, colored points
Slider-Crank (曲柄滑块): O=(0,0) α=angle° r=crank L=coupler A = O + (rcos(α), rsin(α)) c = Circle(A, L) guide = Line((0,-r), (10,-r)) B = Intersect(c, guide, 1) Segment(O, A) Segment(A, B) Circle(B, 0.1) Animate: StartAnimation(α)
Double-Crank / Drag-Link: O1=(0,0) O2=(d,0) α=angle° r1,r2=crank lengths L=coupler A = O1 + (r1cos(α), r1sin(α)) B = O2 + (r2cos(α+offset), r2sin(α+offset)) Segment(O1,A) Segment(A,B) Segment(B,O2) Animate: StartAnimation(α)
Four-Bar Linkage (general): Same as crank-rocker but adjust lengths. Valid if shortest+longest ≤ sum of other two.
── design_json FORMAT ── { "perspective": "G", "animate": "α", "speed": 0.5, "commands": ["O1=(0,0)", "O2=(6,0)", "α=45°", ...], "styles": [ {"label": "A", "color": [1,0,0], "point_size": 5}, {"label": "Segment(O1,A)", "thickness": 5}, {"label": "O1", "point_size": 6, "color": [0,0,0]} ] }
── WORKFLOW ──
New construction (automatic)
Execute commands in order
Apply styles (colors, thickness, point sizes)
Start animation on the angle slider
Auto-zoom and save .ggb + .png
Args: name: Mechanism name (used for filename) design_json: JSON string with design (see format above) output_dir: Output directory (default: current working directory)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| design_json | Yes | ||
| output_dir | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |