Class TransformationUtil
Utilities for the ProgramToMcTransform chain.
Each entry is {Source, Kind, Mat4d}; entries are composed in order
with pure matrix multiplication (GetComposedTransform(JsonObject)).
KindKey partitions the entries by contour validity:
- KindStatic — the matrix is valid across the whole block, applicable to any interpolated point along the contour.
- KindDynamic — the matrix is a block-endpoint snapshot of a rotary-state-dependent transform (RTCP rotary-dynamic). Composing it produces a correct endpoint MC, but interpolated points along the contour must be derived per-step by motion semantics (ClLinearMotionSemantic); do not apply it to interpolated ProgramXyz.
public static class TransformationUtil
- Inheritance
-
TransformationUtil
- Inherited Members
Fields
KindDynamic
The entry's Mat4d is a block-endpoint snapshot only; intermediate contour points must be resolved by per-step IK in motion semantics.
public const string KindDynamic = "Dynamic"
Field Value
KindKey
JSON key for the entry's contour-validity classification. Value must be KindStatic or KindDynamic.
public const string KindKey = "Kind"
Field Value
KindStatic
The entry's Mat4d is valid for any point along the contour.
public const string KindStatic = "Static"
Field Value
Mat4dKey
JSON key for the Mat4d snapshot inside each chain entry.
public const string Mat4dKey = "Mat4d"
Field Value
PivotTransformSource
Canonical source name for the RTCP pivot transform — the kinematic transform from Pn (post-G54, post-G68.2) to MC at the block's endpoint ABC. Contributed by PivotTransformationSyntax. Must be the last entry written into the chain so that all Pn-frame operations (tilt, tool-height, coord-offset) are accumulated before the final kinematic IK; this ordering is enforced by the syntax- chain registration order, not by the writer API.
public const string PivotTransformSource = "PivotTransform"
Field Value
SourceKey
JSON key for the transform origin label inside each chain entry.
public const string SourceKey = "Source"
Field Value
ToolHeightCompensationSource
Canonical source name for the tool-height-compensation entry
(tool-normal · offset_mm along the current tool axis). Matches the
ToolHeightCompensation section key read for
Offset_mm.
public const string ToolHeightCompensationSource = "ToolHeightCompensation"
Field Value
Methods
AddOrReplaceTransform(JsonObject, string, string, Mat4d)
Adds or replaces a named transformation entry in the chain.
If an entry with the same source already exists, it is replaced in-place.
Otherwise the new entry is appended.
kind must be KindStatic or KindDynamic.
public static void AddOrReplaceTransform(JsonObject json, string source, string kind, Mat4d mat)
Parameters
jsonJsonObjectsourcestringkindstringmatMat4d
GetComposedTransform(JsonObject)
Composes all entries in the chain into a single block-endpoint Mat4d (left-to-right multiplication). Pure multiplication — no special cases, no kinematic lookup. The returned matrix is valid only for the block's endpoint state; see ProgramToMcTransform for the endpoint-semantic contract.
public static Mat4d GetComposedTransform(JsonObject json)
Parameters
jsonJsonObject
Returns
GetTransformBySource(JsonObject, string)
Gets a specific entry's Mat4d by source name. Returns identity if not found.
public static Mat4d GetTransformBySource(JsonObject json, string source)
Parameters
jsonJsonObjectsourcestring
Returns
HasDynamicEntry(JsonObject)
Returns true if any entry in the chain carries
KindDynamic. Used by motion-form selection
(LinearMotionSyntax) and ProgramXyz
strategy dispatch (ProgramXyzUtil) to
detect RTCP-rotary-dynamic state without consulting a flag on a
sibling section. Throws if any entry lacks KindKey.
public static bool HasDynamicEntry(JsonObject json)
Parameters
jsonJsonObject
Returns
MakePivotTransformMat(IMachineKinematics, Vec3d)
Builds the PivotTransformSource Mat4d — an
empirically-constructed Pn→MC rigid-affine transform at the block's
endpoint ABC. Equivalent to
kinematics.PnToMc(pn_input, normal).Point when applied to
a Pn-frame point, but expressed as a reusable Mat4d so the chain
stays a pure matrix product (no per-point IK call inside
GetComposedTransform(JsonObject)).
Constructed by probing McToPn(DVec3d) at
the four standard basis points (origin + XYZ unit vectors) at the
target ABC to derive K(abc), and similarly at ABC=0 to derive
K(0); returns K(0) · K(abc).GetInverse(). Topology-
agnostic — works for any affine kinematic chain regardless of axis
order. Legacy PnToMc(DVec3d, out DVec3d) remains the
reference oracle.
public static Mat4d MakePivotTransformMat(IMachineKinematics kinematics, Vec3d abc_rad)
Parameters
kinematicsIMachineKinematicsabc_radVec3d
Returns
MakeToolHeightMat(IMachineKinematics, Vec3d, double)
Builds the tool-height-compensation Mat4d for a given rotary state:
translate by (tool-normal at abc_rad) · height_mm.
Pure translation (no rotation component); combines with the
downstream PivotTransformSource to form the full
Pn→MC IK.
public static Mat4d MakeToolHeightMat(IMachineKinematics kinematics, Vec3d abc_rad, double height_mm)
Parameters
kinematicsIMachineKinematicsabc_radVec3dheight_mmdouble