smbSetTransformationMatrix
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - SimMechanics
Introduced first in SolidGeometry 3.0, Creation date: 2016-11-13, Last change: 2025-09-14
Sets a Block Transformation
Description
Only the R and t part of the HT matrix are used. If the third parameter is used, the Rotation part is turned
rel='match' - T is unchanged
rel='align' - T is turned around y-axis
See Also: smbSetTransformationMatrix
, smbSetRotationMatrix
, smbSetTranslationVector
, smbCreateSG
Example Illustration
Syntax
smbSetTransformationMatrix(BName,T,[rel])
Input Parameter
BName: | | Block Name or gcb |
T: | | 4x4 Transformation Matrix |
rel: | | default is 'match' |
Copyright 2016-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, smbSetTransformationMatrix, is designed to set a transformation matrix for a specified block in a simulation environment. It is part of the SG-Library and was created by Tim Lueth.
Input Parameters
- BName: This is the name of the block for which the transformation matrix is being set. If this parameter is empty, the function defaults to using the current block context, represented by
gcb (get current block).
- T: A 4x4 transformation matrix that includes both rotation and translation components. The function uses only the rotation (R) and translation (t) parts of this matrix.
- rel: An optional parameter that specifies the spatial relationship. It defaults to 'match' if not provided. The possible values are:
- 'match': The transformation matrix
T is used as is, without any modification.
- 'align': The rotation part of the matrix
T is modified by rotating it around the y-axis by 180 degrees (À radians).
Algorithm Steps
- Check if
BName is empty. If it is, set BName to gcb.
- Set the default value of
rel to 'match'. If a third argument is provided and is not empty, update rel with this value.
- Use a
switch statement to handle the rel parameter:
- Case 'match': The transformation matrix
T remains unchanged.
- Case 'align': The rotation part of
T is modified by multiplying it with a rotation matrix that represents a 180-degree rotation around the y-axis.
- Otherwise: If
rel is not recognized, an error is thrown indicating an unknown spatial relation.
- Call
smbSetRotationMatrix with BName and the rotation part of T (first 3x3 submatrix).
- Call
smbSetTranslationVector with BName and the translation part of T (first 3 elements of the fourth column).
Algorithm explaination created using ChatGPT on 2025-08-19 01:00. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21