Table of Contents

Class TransformationUtil

Namespace
Hi.NcParsers.Syntaxs
Assembly
HiMech.dll

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.
Both kinds carry a real Mat4d so composition stays a pure matrix product — no entry has a missing matrix. Use HasDynamicEntry(JsonObject) to detect the dynamic-rotary state without consulting a sibling section flag.
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

string

KindKey

JSON key for the entry's contour-validity classification. Value must be KindStatic or KindDynamic.

public const string KindKey = "Kind"

Field Value

string

KindStatic

The entry's Mat4d is valid for any point along the contour.

public const string KindStatic = "Static"

Field Value

string

Mat4dKey

JSON key for the Mat4d snapshot inside each chain entry.

public const string Mat4dKey = "Mat4d"

Field Value

string

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

string

SourceKey

JSON key for the transform origin label inside each chain entry.

public const string SourceKey = "Source"

Field Value

string

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

string

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

json JsonObject
source string
kind string
mat Mat4d

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

json JsonObject

Returns

Mat4d

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

json JsonObject
source string

Returns

Mat4d

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

json JsonObject

Returns

bool

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

kinematics IMachineKinematics
abc_rad Vec3d

Returns

Mat4d

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

kinematics IMachineKinematics
abc_rad Vec3d
height_mm double

Returns

Mat4d