In the framework FEX, How do I change the projection of 3d points in a different 2D plane (currently it is in XY and want to change it to YX)
1 次查看(过去 30 天)
显示 更早的评论
This is the FEX framework https://www.mathworks.com/matlabcentral/fileexchange/87584-object-oriented-tools-for-fitting-conics-and-quad.
I am using it to fit a plane to my 3D data. It projects data in 2D plane xy, I like to change it to project it in yx plane.
These are the 2 lines of code used for this
pFit=planarFit(XYZ0);%Preliminary plane fit
xy0=pFit.project2D(XYZ0); %Map measured 3D samples to 2D
The implementation of project2D is like this
function xy=project2D(obj,XYZ,type)
%Project a set of 3D coordinates into a 2D coordinate system on the
%fitted plane.
%
% xy=obj.project2D(XYZ)
% xy=obj.project2D(XYZ,type)
%in:
%
% XYZ: A 3xN matrix of 3D coordinates.
%
% type: A string flag, either 'position' (the default) or
% 'direction'.
% With type='position', the XYZ data are assumed
% to be the positions of points relative to the 3D origin.
% Otherwise, XYZ are assumed to be 3D direction vectors,
% with no specific location.
%
%out:
% xy: A 2xN matrix of projected 2D coordinates.
if nargin<3, type='position'; end
B = obj.R(:,[2,3]);
b0 = (obj.normal*obj.distance).';
switch validatestring(type,{'position','direction'})
case 'position'
xy=B.'*(XYZ-b0);
case 'direction'
xy=B.'*XYZ;
end
end
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Biological and Health Sciences 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!