rigidtform2d: why not accept double type homogenous matrix?

2 Ansichten (letzte 30 Tage)
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:
rcond(T)
ans =
0.0473
However it doesn't, which means double is more sensitive than single? Or that the function is not robust enough?

Akzeptierte Antwort

cui,xingxing
cui,xingxing am 29 Okt. 2022
Bearbeitet: cui,xingxing am 29 Okt. 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.
coder.inline('always');
coder.internal.prefer_const(A,B);
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;
end

Weitere Antworten (0)

Kategorien

Mehr zu Geometric Transformation and Image Registration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by