-
Notifications
You must be signed in to change notification settings - Fork 96
/
homoTrans.m
56 lines (45 loc) · 1.59 KB
/
homoTrans.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
% HOMOTRANS - homogeneous transformation of points
%
% Function to perform a transformation on homogeneous points/lines
% The resulting points are normalised to have a homogeneous scale of 1
%
% Usage:
% t = homoTrans(P,v);
%
% Arguments:
% P - 3 x 3 or 4 x 4 transformation matrix
% v - 3 x n or 4 x n matrix of points/lines
% Copyright (C) 1993-2011, by Peter I. Corke
%
% This file is part of The Machine Vision Toolbox for Matlab (MVTB).
%
% MVTB is free software: you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% MVTB is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU Lesser General Public License for more details.
%
% You should have received a copy of the GNU Leser General Public License
% along with MVTB. If not, see <http://www.gnu.org/licenses/>.
% Peter Kovesi
% School of Computer Science & Software Engineering
% The University of Western Australia
% pk @ csse uwa edu au
% http://www.csse.uwa.edu.au/~pk
%
% April 2000
% September 2007
function t = homotrans(P,v);
[dim,npts] = size(v);
if ~all(size(P)==dim)
error('Transformation matrix and point dimensions do not match');
end
t = P*v; % Transform
for r = 1:dim-1 % Now normalise
t(r,:) = t(r,:)./t(end,:);
end
t(end,:) = ones(1,npts);