How can I transform a coordinates data into another 3-D space?
1 次查看(过去 30 天)
显示 更早的评论
suppose that I have coordinates of 4 points X1, X2, X3, and X4 which have form of Xi = [xi1; xi2; xi3; xi4] for i = 1~4 . Their relative position to each other never change. But the whole coordinates were rotated in some way, and now I measured the coordinates of X'1, X'2, and X'3 but not X'4. In this case how can I find the coordinates of X'4 in new 3D space? What function can I use?
+) If there is a linear transform T with 3x3 size matrix that satisfies T*[X1 X2 X3] = [X'1 X'2 X'3] then is it unique?
2 个评论
Matt J
2018-6-21
If there is a linear transform T with 3x3 size matrix that satisfies T[X1 X2 X3] = [X'1 X'2 X'3] then is it unique?*
But you said your Xi are 4x1 column vectors. How can they multiply with a 3x3 matrix?
采纳的回答
更多回答(2 个)
Mark Saad
2018-6-21
If you know angles through which they were rotated, you could try using rotation matrices.
https://www.mathworks.com/help/phased/ref/rotx.html
0 个评论
Anton Semechko
2018-6-21
Code below demonstrates how to obtain rotation matrices between corresponding 3-tupples of non-collinear points in 3-space:
function three_point_rotation_demo
% Generate 3 random points and random rotation
% -------------------------------------------------------------------------
% 3 (noncollinear) data points
Xo=randn(3,3); % xyz-coordiantes along rows
% Random rotation matrix
r=randn(3,1);
r=r/norm(r); % direction of rotation vector
t=(178*rand(1)+1)*(pi/180); % rotation amount; between 1 and 179 degrees
r=t*r; % random rotation vector
K=zeros(3);
K(1,2)=-r(3);
K(1,3)= r(2);
K(2,3)=-r(1);
K=K-K'; % log of rotation matrix
Ro=expm(K); % rotation matrix corresponding to r
% Apply R to Xo to get X
X=(Ro*(Xo'))';
% Now, suppose that Ro (i.e., rotation that transforms Xo to X) is unknown.
% -------------------------------------------------------------------------
% Compute local (orthogonal) reference frame for X
d21=X(2,:)-X(1,:);
d31=X(3,:)-X(1,:);
e1=d21; e1=e1/norm(e1);
e2=d31-dot(e1,d31)*e1; e2=e2/norm(e2);
e3=cross(e1,e2); e3=e3/norm(e3);
F=[e1;e2;e3]'; % principal axes along columns
% Compute local (orthogonal) reference frame for Xo
d21=Xo(2,:)-Xo(1,:);
d31=Xo(3,:)-Xo(1,:);
e1=d21; e1=e1/norm(e1);
e2=d31-dot(e1,d31)*e1; e2=e2/norm(e2);
e3=cross(e1,e2); e3=e3/norm(e3);
Fo=[e1;e2;e3]';
% Rotation we seek (R) satisfies the equation F=R*Fo. Since Fo and F are
% orhogonal rotation matrices themselves, R=F*transpose(Fo)
R=F*(Fo');
% Now let's check that R is the same (up to numerical round off error) as
% Ro. If it is then R'*Ro should be a 3-by-3 matrix close to identity.
fprintf('Rotation residual:\n')
disp(R'*Ro)
% You can also verify that X=(R*(Xo'))', in which case, (R*(Xo'))'-X will be
% a 3-by-3 matrix with all entries very close to zero
fprintf('\nFrobenius norm of (R*(Xo''))''-X:\n')
disp(norm((R*(Xo'))'-X,'fro'))
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Scene Control 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!