Syntax
NT=Trotate(T,[ax,val])
Input Parameter
T : | | Transformation matrix |
ax : | | rotation axis 'x,'y','z' or axial, coronal, sagittal |
val : | | value; default is p/2 |
Output Parameter
NT : | | New Transformation matrix |
Examples
Trotate(eye(4),'s')
Copyright 2020-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, Trotate, is designed to apply a rotation to a given transformation matrix T. It is part of the SolidGeometry library and is used for kinematics and frame transformations.
Input Parameters
- T: A transformation matrix that represents the initial state.
- ax: A string indicating the axis of rotation. It can be 'x', 'y', 'z', 'a' (axial), 'c' (coronal), 's' (sagittal), or 'r' (random).
- val: The angle of rotation in radians. The default value is À/2.
Output
- NT: The new transformation matrix after applying the specified rotation.
Algorithm Steps
- Check if the transformation matrix T is empty. If it is, an error is thrown.
- Retrieve the rotation axis (ax) and the rotation value (val) from the input parameters. If not provided, default values are used.
- Convert the axis to lowercase and initialize a 3x3 identity matrix R for rotation.
- If val is a scalar, replicate it to match the length of ax.
- Iterate over each character in ax to determine the rotation:
- Case 'a': No change, R remains the identity matrix.
- Case 'c': Apply a coronal rotation using rot(À/2,0,0).
- Case 's': Apply a sagittal rotation using rot(0,À/2,0).
- Case 'r': Apply a random rotation using random values for each axis.
- Case 'x': Apply a rotation around the x-axis using rot(val(i),0,0).
- Case 'y': Apply a rotation around the y-axis using rot(0,val(i),0).
- Case 'z': Apply a rotation around the z-axis using rot(0,0,val(i)).
- Default: If an unrecognized axis is provided, a warning is issued, and R remains the identity matrix.
- Update the transformation matrix NT by applying the rotation matrix R to T. If T is a 3D matrix, apply the rotation to each slice.
- If no output is requested, plot the new transformation matrix using SGfigure and tplot functions.
Algorithm explaination created using ChatGPT on 2025-08-19 07:56. (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