geometry.transform — Move, rotate, or otherwise affinely transform a geometry feature.
feature = geometry.transform(source, T) returns a geometry.Feature whose result is source mapped by the 4-by-4 homogeneous affine transform T, where a point p moves to T(1:3,1:3)*p + T(1:3,4).
Syntax
feature = geometry.transform(source, matrix)Inputs
source- Type
Any- Required
- Yes
- Default
- —
- Description
- geometry.Feature to transform.
matrix- Type
NumericArray- Required
- Yes
- Default
- —
- Description
- 4-by-4 homogeneous affine transform: T(1:3,1:3) linear part, T(1:3,4) translation in meters, final row [0 0 0 1].
Returns
feature- Type
Any- Description
- geometry.Feature whose result is the transformed source.
Errors
RunMat:geometry:transform:InvalidInput- When
- The wrong number of arguments is passed. source is not a geometry.Feature, or matrix is not a finite real 4-by-4 matrix whose final row is [0 0 0 1]. A value violates the feature-graph contract.
- Message
geometry.transform: invalid input
Behavior
T is a 4-by-4 real matrix. T(1:3,1:3) is the linear part (rotation, and optionally scaling or shear) and T(1:3,4) is the translation in meters; the final row must be [0 0 0 1]. A pure translation is T = eye(4); T(1:3,4) = [dx; dy; dz];.
The call checks that T is a finite real 4-by-4 matrix with final row [0 0 0 1] and converts it to the row-major form that the exact-CAD kernel consumes, so the transform you write is the one that is realized. The result is one new feature that depends on source; source itself is unchanged and remains usable.
The call records construction intent only. It appends one operation to an immutable, content-addressed feature graph and returns a new geometry.Feature; it does not run a CAD kernel, tessellate, or touch the filesystem. The graph is realized as exact B-rep topology when a .fea geometry declaration that imports the generating function is materialized for meshing or analysis.
All lengths are meters and all angles are radians; there is no unit option. Scalars accept double, single, or an exactly representable integer-class scalar. Vector arguments must be real, finite, non-integer-class numeric arrays with the stated element count; row and column orientation are both accepted.
Every failure, including the wrong number of arguments, a value of the wrong kind, and a value that violates the feature-graph contract (a nonpositive or non-finite length, radius, depth, distance, or angle, or an all-zero direction), raises the builtin's own RunMat:geometry:<name>:InvalidInput identifier, and no value is returned. Feature identities are derived from a digest of each operation, so repeating the same construction yields the same feature identity.
Use in a study
Return the finished part from a pure .m function: geometry.finish(feature) turns the final feature into a geometry.Generated product, and geometry.withRegion publishes typed selections under names. A .fea geometry declaration written as generated by function.<name> calls that function, realizes the exact geometry, and exposes each named selection as output.region.<name> for meshing, material assignment, constraints, and loads.
Use geometry.transform to position primitives before Boolean operations, since primitives are created at fixed reference positions. To place several copies of one feature, use geometry.instance.
Errors
RunMat:geometry:transform:InvalidInput reports every failure of the call: the wrong number of arguments, a source that is not a geometry.Feature, or a matrix that is not a finite real 4-by-4 matrix with final row [0 0 0 1], or a value that violates the feature-graph contract, such as a zero or negative dimension, a non-finite value, or an all-zero direction. A failed call returns nothing, and earlier values are unchanged because builder values are immutable.
Examples
Move a plate 100 mm along x
plate = geometry.box(80e-3, 50e-3, 8e-3);
T = eye(4);
T(1:3, 4) = [100e-3; 0; 0];
moved = geometry.transform(plate, T);
class(moved)Rotate a plate 90 degrees about z and lift it 10 mm
plate = geometry.box(80e-3, 50e-3, 8e-3);
c = cos(pi/2); s = sin(pi/2);
T = eye(4);
T(1:2, 1:2) = [c -s; s c];
T(1:3, 4) = [0; 0; 10e-3];
turned = geometry.transform(plate, T);
class(turned)A matrix whose final row is not [0 0 0 1] is rejected
plate = geometry.box(80e-3, 50e-3, 8e-3);
T = eye(4);
T(4, 1) = 0.5;
moved = geometry.transform(plate, T);A 3-by-3 matrix is rejected
plate = geometry.box(80e-3, 50e-3, 8e-3);
moved = geometry.transform(plate, eye(3));Using geometry.transform with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how geometry.transform changes the result.
Run a small geometry.transform example, explain the result, then change one input and compare the output.
FAQ
How do I rotate a part about the z axis?⌄
Put a rotation in the linear part: c = cos(theta); s = sin(theta); T = eye(4); T(1:2,1:2) = [c -s; s c];. Rotation is about the origin, so translate first if you need a different pivot.
How do I enter millimeter dimensions?⌄
Convert to meters before the call, for example geometry.box(80e-3, 50e-3, 8e-3). When the function is called from a .fea declaration, length inputs already arrive in meters.
Related Geometry functions
Construction
geometry.box · geometry.chamfer · geometry.cylinder · geometry.edges · geometry.edgesIntroducedBy · geometry.extrude · geometry.faces · geometry.facesIntroducedBy · geometry.fillet · geometry.finish · geometry.hole · geometry.instance · geometry.intersect · geometry.pocket · geometry.revolve · geometry.solid · geometry.sphere · geometry.subtract · geometry.union · geometry.withRegion
Related guides
Source you can read
Every RunMat function's source is public. Read exactly how geometry.transform is executed, line by line, in Rust.
- View the source for geometry.transform in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.