Table of Contents

Mat4dControl Component

Mat4dControl edits and displays a 4x4 transform matrix. It is an embedded widget with no route and no Control-Tree node of its own, reached only through the editor that hosts it.

Key Model

The persisted model is mat4d_t, the value struct that mirrors the native mat4d_t; it has no REST surface of its own (the key-edited /api/Mat4d controller was removed with the struct), so every edit reaches the matrix through the object that owns it.

The widget's own model is a plain array of sixteen numbers, exported as type Mat4 from wwwroot-src/src/components/widgets/Mat4Input.vue. The layout is column-major, matching the backend mat4d_t: cell (row, col) resolves to index col * 4 + row, so indices 0 to 3 are the first column and 12 to 15 the translation column. wwwroot-src/src/api/transformer.ts states the same column-major contract on the wire. A model shorter than sixteen numbers, or not an array at all, is padded out with zeros before display, and a longer one is truncated to sixteen.

The widget carries no key and calls no endpoint. Its host, wwwroot-src/src/components/topo/StaticFreeformEditor.vue, binds it with v-model and persists each change through updateStaticFreeformMat from wwwroot-src/src/api/transformer.ts, which posts the whole sixteen-number array to /api/StaticFreeform/Update; Mech/Topo/StaticFreeformController.cs rejects a payload that is not exactly sixteen elements.

The props are modelValue, disable, readonly, identity (on by default) and invert (off by default), and the emits are update:modelValue, identity and invert. disable both disables the cells and dims the whole block.

Layout

  • Mat4dControl
    • Matrix Grid — four rows of four numeric cells, each cell right-aligned
    • Identity Button — present when the identity flag is set, which is the default
    • Invert Button — present only when the invert flag is set

The cells and both buttons are inactive while the control is disabled or readonly.

Feature

Single input mode

The grid of sixteen cells is the only editing surface, and each cell shows the full precision of its number with no rounding for display.

Matrix operations

  • Identity — the button raises an identity event and writes nothing itself; the host supplies the matrix. StaticFreeformEditor pushes its own identity constant through updateStaticFreeformMat.
  • Invert — the button raises an invert event and computes nothing itself. StaticFreeformEditor calls invertStaticFreeformMat, which posts to /api/StaticFreeform/InvertMat and feeds the sixteen numbers that come back into the model. A singular matrix — one with a zero determinant, such as the identity with one diagonal cell set to 0 — is refused with 400 Matrix is not invertible: the editor raises its error event with that message, writes nothing, and the grid keeps the matrix it shows. Up to 3.2.38 the route answered 200 with sixteen Infinity / NaN literals, which the editor wrote back into the transformer and this grid showed as Infinity and 0.

Commit and special values

Each cell commits on blur or Enter — not on the Enter that confirms an IME conversion, and a cell's full-width digits and signs are read as ASCII, as in Numeric Input — and the widget emits the entire sixteen-number array rather than a single index. An unparseable cell reverts to its previous value, an empty cell becomes 0, and a cell whose parsed value is unchanged emits nothing. Formatting and parsing are local to the component: Infinity and -Infinity are shown and parsed as literal text, while NaN and a missing cell both display as 0, so NaN is not round-tripped.

Source Code Path

See HiNC App Anatomy for git repository links.

  • wwwroot-src/src/components/widgets/Mat4Input.vue — the widget itself: the column-major sixteen-cell grid, the Identity and Invert buttons, and the local format, parse and commit helpers
  • wwwroot-src/src/components/topo/StaticFreeformEditor.vue — the host, and the full binding contract in one place: v-model, the two button flags, @update:model-value, @identity, @invert
  • wwwroot-src/src/api/transformer.ts — updateStaticFreeformMat and invertStaticFreeformMat
  • Mech/Topo/StaticFreeformController.cs — the backend behind those two endpoints: Update takes a sixteen-element array, InvertMat returns the inverted sixteen numbers or 400 Matrix is not invertible when the inverse has a non-finite element (mat4d_t.IsFinite); its REST contract is .ai/static-freeform-invert-e2e.mjs
  • there is no Mat4dController any more: the /api/Mat4d REST surface (New, NewWithValue, Get, Update, UpdateAt, ParseAndUpdate, SetIdentity, Transpose, Inverse) edited a registry-held matrix by key and was removed when mat4d_t became a value; the SPA never called it, and the widget's host persists through the StaticFreeform endpoints
  • wwwroot-src/src/i18n/en/widgets.ts — the Invert label and both button tooltips under widgets.matInput

See Also

  • Vec3dControl Component — the sibling numeric-geometry editor, and the one a reader usually wants next
  • Numeric Input/Output — why NaN and the infinities are text on the wire, and why NaN does not survive this grid