why use transposed matrix in affine2d

自作多情 提交于 2019-12-23 17:18:25

问题


According to http://nl.mathworks.com/help/images/ref/affine2d-class.html

Matlab expects a transposed affine transform matrix, and it applies the transform by vT with v as a row vector instead of the standard Tv where v is a column vector.

They say a valid matrix is of the form [a b 0; c d 0; e f 1] a transpose of the common form in the literature - and what you expect when they multiply vT instead of Tv.

Because of this, their example does a clock-wise rotation instead of a counter-clock-wise (even though they say it should do a counter-clock-wise):

%Define 10-Degree Rotation in the Counter-Clockwise Direction
%Create an affine2d object that defines the transformation.
theta = 10;
tform = affine2d([cosd(theta) -sind(theta) 0; sind(theta) cosd(theta) 0; 0 0 1])
%Apply forward geometric transformation to an input (U,V) point (5,10).
[X,Y] = transformPointsForward(tform,5,10)
X = 6.6605
Y = 8.9798

They use the literature matrix for ccw rotation, but multiply in the opposite order, so they get a cw rotation... if they would transpose the matrix, it would indeed do a ccw rotation (maybe they forgot to do that in the example).

I've tested the speed of multiplying the matrix by vector from the left vs multiplying the vector by matrix - and the difference is negligible.

I guess it was a bug and they kept it for backwards compatibility? Anyone has any insight on this?

来源:https://stackoverflow.com/questions/34059835/why-use-transposed-matrix-in-affine2d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!