rigidtform2d: why not accept double type homogenous matrix?

2 ビュー (過去 30 日間)
cui,xingxing
cui,xingxing 2022 年 10 月 29 日
編集済み: cui,xingxing 2022 年 10 月 29 日
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?

採用された回答

cui,xingxing
cui,xingxing 2022 年 10 月 29 日
編集済み: cui,xingxing 2022 年 10 月 29 日
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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by