w=wofT(T2)
T2 : | HT Matrix in 2D = 3x3xM |
w : | angle list |
wofT(TofR(rot(pi/3)))-pi/3
This function, wofT
, is designed to compute the angle from a 2D homogeneous transformation matrix. It is part of the SolidGeometry library and was introduced in version 4.5. The function is authored by Tim Lueth and is intended for analytical geometry applications.
The function begins by checking if the second dimension of the input matrix T2
is equal to 3. This check ensures that the input is a 3x3 matrix, which is a requirement for 2D homogeneous transformation matrices.
If the input matrix meets this condition, the function proceeds to calculate the angle using the atan2
function. The atan2
function computes the arctangent of the quotient of its arguments, which in this case are the elements T2(2,1,:)
and T2(1,1,:)
of the matrix. These elements correspond to the sine and cosine of the rotation angle, respectively.
The squeeze
function is then used to remove any singleton dimensions from the resulting array, effectively producing a list of angles.
If the input matrix does not meet the 3x3 requirement, the function throws an error message indicating that the implementation is only available for 2D matrices. It suggests using the rotm2eul
function from Peter Corke's library for Euler angles in other dimensions.
An example provided in the comments demonstrates the use of the function:
w = wofT(TofR(rot(pi/3))) - pi/3
This example shows how to use the function to compute the angle from a rotation matrix generated by a rotation of pi/3
radians.