Skip to content

fix(hypergraph): keep a slider's line through from_mechanism, count pairs in indeterminacy - #61

Merged
HugoFara merged 2 commits into
mainfrom
fix/mechanism-slider-round-trip
Sep 18, 2026
Merged

HugoFara merged 2 commits into
mainfrom
fix/mechanism-slider-round-trip

Conversation

@HugoFara

Copy link
Copy Markdown
Owner

Follow-up to #60 / #56 — the three gaps noted there.

from_mechanism keeps a PrismaticJoint's slide line. A PrismaticJoint has line_point and axis but no joints on the line, so nothing was emitted for it and slider_crank() → from_mechanism → to_mechanism failed with "Could not determine solve order". It now writes the encoding to_mechanism reads: a hyperedge over the slider and two ground nodes on the line. Ground joints already on the line are reused (the motor pivot of slider_crank() is one), and missing ones are added as <id>_rail0 / <id>_rail1 at line_point and one axis length along. The round trip reproduces the original to ~1e-15 for horizontal, slanted and vertical rails, and a second pass adds no node.

to_mechanism refuses a prismatic driver node. A LinearActuator was silently built as a rotary crank. Mechanism has no linear driver link, so this is now a NotImplementedError with the reason — adding a LinearDriverLink is a feature (step, derivatives, builder, serialization, numba path) and out of scope here.

Mechanism.indeterminacy() counts pairs, not joints. A joint on k links joins them with k − 1 pairs: a ground joint that only marks a point of the frame, or a coupler point, is no pair, and a PrismaticJoint adds the prismatic pair with the frame its slide line stands for. The round-tripped slider-crank reported −1, a four-bar with a coupler point and a frame mark −3; both report 1 now. fourbar() and slider_crank() are unchanged at 1.

…airs in indeterminacy

Three loose ends from #56 (PR #60).

from_mechanism dropped the slide line of a PrismaticJoint, which has
line_point and axis but no joints on the line to hang a hyperedge on,
so slider_crank() → from_mechanism → to_mechanism failed with "Could
not determine solve order". It now writes the encoding to_mechanism
reads: a hyperedge over the slider and two ground nodes on the line.
Ground joints already on the line are reused, and missing ones are
added as <id>_rail0 / <id>_rail1 at line_point and one axis length
along. The round trip reproduces the original simulation and a second
pass adds no node.

to_mechanism built a prismatic driver node — a LinearActuator — as a
rotary crank without a word. Mechanism has no linear driver link, so it
now raises NotImplementedError.

Mechanism.indeterminacy() counted every joint as a kinematic pair. A
joint on k links joins them with k − 1 pairs: a ground joint that only
marks a point of the frame, or a coupler point, is no pair, and a
PrismaticJoint adds the prismatic pair with the frame its slide line
stands for. The round-tripped slider-crank reported −1, a four-bar with
a coupler point and a frame mark −3; both are 1 now.
@HugoFara
HugoFara merged commit 7ce31e9 into main Sep 18, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant