📄 transform.m
字号:
function coords = transform(coords, matrix, offset)%coords = TRANSFORM(coords, matrix, offset)%%Transform points with respect to the transformation matrix and offset%%Input:% COORDS - coordinates of points (array with the last dimension 2 or 3)% MATRIX - matrix which should be applied% OFFSET - offset of points (default 0)%%Output:% COORDS - new coordinates of the points%%Notes:% The transformation works for both 2-D and 3-D data.% If the dimension of MATRIX is 3x3 (or 2x2 for 2-D case), normal matrix% multiplication is performed. If the dimension is 4x4 (or 3x3 for 2-D case,% homogeneous coordinates are used for the computation. If OFFSET is given,% the points are shifted by this offset before the multiplication.%%See also:% ROTMATRIX, DIR2ROT%%Radim Halir, Charles University Prague, halir@ms.mff.cuni.cz%Created: 25.9.1996%Last modified 14.1.1998dims = size(coords);[array, m, n] = data2cols(coords);if (nargin > 2) array = mvop(array, offset, '+');end homogen = (size(matrix, 1) ~= n);if (homogen) array = [array, ones(prod(m), 1)];endarray = array * matrix.';if (homogen) array = mvop(array(:, 1 : n), array(:, n + 1), './');endcoords = reshape(array, dims);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -