rigidtform2d: why not accept double type homogenous matrix?

1 view (last 30 days)
I found out by accident why the function rigidtform2d does not accept a 3 by 3 flush matrix of type double?
T = [ 1.0000 0.0004 -0.2102
-0.0004 1.0000 3.3896
0 0 1.0000]; % T is default double type
A = rigidtform2d(single(T)); % ok
B = rigidtform2d(T);
Error using rigidtform2d>parseOneInputSyntaxes
Invalid transformation matrix.

Error in rigidtform2d (line 40)
self = parseOneInputSyntaxes(self,varargin{1});
I then test to see if it is close to the singular matrix:
ans =
However it doesn't, which means double is more sensitive than single? Or that the function is not robust enough?

Accepted Answer

cui on 29 Oct 2022
Edited: cui on 29 Oct 2022
A rigidtform2d object stores only rotation and translation information, and the shear 0.0004 exists in the T matrix above.
It is actually a robustness problem, Hopefully future versions enhance the double type of issue,caused by the following functions:
the constrained matrix is not within floating-point round-off error of the original matrix, then the original matrix is not a valid transformation matrix for the subclass.
function tf = matricesNearlyEqual(A,B)
% matricesNearlyEqual
% matricesNearlyEqual(A,B) returns true if A and B are the
% same, within floating-point round-off error. A and B are assumed to
% be square and of the same class, and this is not checked.
t = eps(class(A)) ^ (3/4);
R = max(norm(A),norm(B));
R0 = 100 * realmin(class(A)) / t;
R = max(R,R0);
tf = (norm(A - B) / R) <= t;

More Answers (0)


Find more on Computer Vision Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!