generate new coordinates (starting from initial coordinates) that are arranged outwards (by a distance H) and on the same plane

2 ビュー (過去 30 日間)
HI! Is there a way to generate new coordinates, starting from the 'trace' matrix, which are arranged outwards (by a distance H) and always on the highlighted plane?
M = [0.138500000000000 0.0645000000000000 0.988300000000000 82.9848687500000];
figure
plot3(trace(:,1),trace(:,2),trace(:,3),'k.','Markersize',10);
hold on
fimplicit3(@(x1,y1,z1) M(1)*x1+M(2)*y1+z1*M(3)-M(4));
hold off
axis equal
zlim([80 84])

採用された回答

Bruno Luong
Bruno Luong 2023 年 9 月 27 日
編集済み: Bruno Luong 2023 年 9 月 27 日
load('trace.mat')
mt = mean(trace);
dt = trace-mt;
[~,~,V]=svd(dt);
Q=V(:,[1:2]);
t2D = dt*Q;
[~,is]=sort(atan2(t2D(:,2),t2D(:,1)));
P=polyshape(t2D(is,:));
Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or unexpected results. Input data has been modified to create a well-defined polyshape.
H = 1;
Pbigger=polybuffer(P,H);
Pbigger3D=mt+Pbigger.Vertices*Q';
figure
plot3(trace(:,1),trace(:,2),trace(:,3),'.')
hold on
plot3(Pbigger3D(:,1),Pbigger3D(:,2),Pbigger3D(:,3),'Linewidth', 2)
axis equal
  3 件のコメント
Bruno Luong
Bruno Luong 2023 年 10 月 1 日
編集済み: Bruno Luong 2023 年 10 月 1 日
Not sure what is "other end nodes"? If you want to densify just interpolate the expalnd nodes using interp1 for example. Each task a specific function, don't mix them.

サインインしてコメントする。

その他の回答 (2 件)

Matt J
Matt J 2023 年 9 月 26 日
編集済み: Matt J 2023 年 9 月 26 日
Project the points into a 2D coordinate system on the plane. Then use polyshape. Then project back to 3D.
load trace
H=0.5;
[~,V]=freeBoundary( delaunayTriangulation(trace(:,1:2)) );
Warning: Duplicate data points have been detected and removed.
The Triangulation indices are defined with respect to the unique set of points in delaunayTriangulation.
p=polyshape(V);
Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or unexpected results. Input data has been modified to create a well-defined polyshape.
q=polybuffer(p,H);
scatter(p.Vertices(:,1), p.Vertices(:,2)); hold on
plot([p,q])
scatter(q.Vertices(:,1), q.Vertices(:,2)); hold off
axis equal
  3 件のコメント
Matt J
Matt J 2023 年 9 月 26 日
Project the 2D results back to 3D.
Alberto Acri
Alberto Acri 2023 年 9 月 26 日
編集済み: Alberto Acri 2023 年 9 月 27 日
Is there a way to get the new coordinates in 3 dimensions?
At the moment I have:
N = [q.Vertices(:,1), q.Vertices(:,2)];
How can I get the third dimension?

サインインしてコメントする。


Walter Roberson
Walter Roberson 2023 年 9 月 26 日
編集済み: Walter Roberson 2023 年 9 月 27 日
which are arranged outwards (by a distance H)
I doubt that you want to arrange the points by distance H, but here it goes.
load trace
axes2 = axes('Parent',figure);
patch(axes2, trace(:,1), trace(:,2), trace(:,3), 'facecolor', 'r', 'facealpha', 0.5, 'edgecolor', 'k');
view(axes2,[31.7625655339418 23.9174311926605]);
axis(axes2, 'equal');
axes3 = axes('Parent', figure);
tc = mean(trace,1);
c = trace - tc;
[th, H, z] = cart2pol(c(:,1), c(:,2), c(:,3)); %center around centroid
[~, order] = sort(H);
patch(axes3, trace(order,1), trace(order,2), trace(order,3), 'facecolor', 'r', 'facealpha', 0.5, 'edgecolor', 'k');
view(axes3,[31.7625655339418 23.9174311926605]);
axis(axes3, 'equal')
axes4 = axes('Parent', figure)
axes4 =
Axes with properties: XLim: [0 1] YLim: [0 1] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0.1300 0.1100 0.7750 0.8150] Units: 'normalized' Use GET to show all properties
[~, order] = sort(th);
patch(axes4, trace(order,1), trace(order,2), trace(order,3), 'facecolor', 'r', 'facealpha', 0.5, 'edgecolor', 'k');
view(axes4,[31.7625655339418 23.9174311926605]);
axis(axes4, 'equal')
As you can see, the plot is a lot more sensible if you sort by angle than by distance.
  2 件のコメント
Alberto Acri
Alberto Acri 2023 年 9 月 27 日
Thanks for the answer but maybe you got confused with my other question.
In this post I would like to generate coordinates outwards from those in 'trance' as Matt has shown. Only I would like the 3D layout.
In your solution, the pink plane generated is the same size as 'trace' (not bigger) and is placed lower than where the 'trace' coordinates are. So I would need to generate coordinates arranged outwards by a distance H that I choose.
load trace
tc = mean(trace,1);
c = trace - tc;
[th, H, z] = cart2pol(c(:,1), c(:,2), c(:,3)); %center around centroid
[~, order] = sort(th);
figure
patch(trace(order,1), trace(order,2), trace(order,3), 'facecolor', 'r', 'facealpha', 0.5, 'edgecolor', 'k');
hold on
plot3(trace(:,1),trace(:,2),trace(:,3),'k.','Markersize',10);
hold off
axis equal
Walter Roberson
Walter Roberson 2023 年 9 月 27 日
format long g
M = [0.138500000000000 0.0645000000000000 0.988300000000000 82.9848687500000];
tolerance = 1e-3;
load trace
d = M(1)*trace(:,1) + M(2)*trace(:,2) + M(3) * trace(:,3) - M(4);
mask = abs(d) < tolerance;
in = trace(mask,:);
out = trace(~mask,:);
scatter3(in(:,1), in(:,2), in(:,3), 'g');
hold on
scatter3(out(:,1), out(:,2), out(:,3), 'r');
hold off
axis equal
[min(d), max(d)]
ans = 1×2
1.0e+00 * -1.4210854715202e-14 1.4210854715202e-14
The interpretation of this is that all of the points in trace are already on that particular plane to within a fairly small tolerance. You cannot expect the distance-from-plane, d, to be exactly 0 due to round-off error.
With all of the points already being on the plane, then the task becomes to sort by H. But what is H ? Distance between some outer ring (the red one) and the inner ring (the black one) ? But is there an equation for either the inner or outer ring with the coordinates inside trace providing the other of the two rings? Your fimplicit() is linear and defining a plane, not a ring of some kind.

サインインしてコメントする。

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by