rot
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 1.0, Creation date: 2006-06-18, Last change: 2025-09-14
returns rotation matrix in 3x3 as Rx*Ry*Rz or 2x2 Rz
Description
For 3D, a rotating using Euler angle X * Y * Z;
in 2D just 1 parameter is used for rot z
This function also shows very simple that cos(pi/2)=0.9996, i.e round to 1/1000 is o.k.
See Also: rot
, rotdeg
Example Illustration
Syntax
R=rot(wx,[wy,wz])
Input Parameter
wx: | | x rotation angle (optional) |
wy: | | y rotation angle (optional) |
wz: | | z rotation angle |
Output Parameter
Examples
rotate around z axis by pi/2:
rot(0,0,pi/2)
rot(pi/2)
Copyright 2006-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 calculates a rotation matrix based on given rotation angles around the x, y, and z axes. It can handle both 2D and 3D rotations.
Input Parameters
- wx: Rotation angle around the x-axis (optional).
- wy: Rotation angle around the y-axis (optional).
- wz: Rotation angle around the z-axis.
Output
- R: A 3x3 rotation matrix for 3D rotations or a 2x2 matrix for 2D rotations.
Algorithm Steps
- Check if the input
wx is a vector with three elements. If so, assign wx, wy, and wz from this vector.
- If only one argument is provided, assume a 2D rotation around the z-axis and return a 2x2 rotation matrix.
- If more than one argument is provided, assign
wy and wz from the additional arguments.
- Calculate the rotation matrix
Rz for the z-axis using the angle wz.
- Calculate the rotation matrix
Rx for the x-axis using the angle wx.
- Calculate the rotation matrix
Ry for the y-axis using the angle wy.
- Compute the final rotation matrix
R by multiplying Rx, Ry, and Rz in that order.
Algorithm explaination created using ChatGPT on 2025-08-19 00:58. (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