xargon
Computer
- Nov 2, 2005
- 1
Hi everyone,
I am trying to understand a particular piece of Matlab code and finding out what it does. Unfortunately, the code does not have much comments and I do not know who the author is. I was wondering if any experts here can take a look at it and help me understand what it actually does.
function ret = find_principal_coordinatess(Ps)
% INPUT: Ps = a set of N point coordinates in a 3 x N or 4 x N (homogeneous form) matrix
X = Ps(1:3,
';
N = size(X,1);
Xm = mean(X);
%Pcentroid = Xm';
X0 = X - repmat(Xm,N,1);
[UX,DX,VX] = svd(X0);
Paxes = [VX
,1:2), cross(VX
,1),VX
,2))];
V1 = repmat(Paxes
,1)',N,1);
V2 = repmat(Paxes
,2)',N,1);
V3 = repmat(Paxes
,3)',N,1);
ret = [sum(X0.*V1,2) sum(X0.*V2,2) sum(X0.*V3,2)]';
Thanks,
-xar
I think it takes a matrix and returns a reference coordinate according to some central values...(?). I am not exactly sure. I would be really grateful if someone could help with this.
I am trying to understand a particular piece of Matlab code and finding out what it does. Unfortunately, the code does not have much comments and I do not know who the author is. I was wondering if any experts here can take a look at it and help me understand what it actually does.
function ret = find_principal_coordinatess(Ps)
% INPUT: Ps = a set of N point coordinates in a 3 x N or 4 x N (homogeneous form) matrix
X = Ps(1:3,
N = size(X,1);
Xm = mean(X);
%Pcentroid = Xm';
X0 = X - repmat(Xm,N,1);
[UX,DX,VX] = svd(X0);
Paxes = [VX
V1 = repmat(Paxes
V2 = repmat(Paxes
V3 = repmat(Paxes
ret = [sum(X0.*V1,2) sum(X0.*V2,2) sum(X0.*V3,2)]';
Thanks,
-xar
I think it takes a matrix and returns a reference coordinate according to some central values...(?). I am not exactly sure. I would be really grateful if someone could help with this.