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 件)
Catalytic
2023 年 7 月 28 日
編集済み: Catalytic
2023 年 7 月 28 日
Since this concerns an FEX submission, you should probably ask the question in the discussion page of that submission.
However, if the only problem is that you are getting coordinates (x,y) and you want coordinates (y,x) then just interchange y and x.
参考
カテゴリ
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!