I need to draw arc through three points in three-dimensional space. Can you please help me out?

2 ビュー (過去 30 日間)
x_i = [0,5,20];
y_i = [0,0,0];
z_i = [20,5,0];
P1 = [x_i(1);y_i(1);z_i(1)]
P1 = 3×1
0 0 20
P2 = [x_i(2);y_i(2);z_i(2)]
P2 = 3×1
5 0 5
P3 = [x_i(3);y_i(3);z_i(3)]
P3 = 3×1
20 0 0
v1 = cross(P2-P1,P3-P1);
v1 = v1/norm(v1)
v1 = 3×1
0 -1 0
syms x y z
P0 = [x;y;z];
eqn1 = dot(P0-P1,v1) == 0
eqn1 = 
eqn2 = dot(P0-(P2+P1)/2,P2-P1) == 0
eqn2 = 
eqn3 = dot(P0-(P3+P1)/2,P3-P1) == 0
eqn3 = 
[A,B] = equationsToMatrix([eqn1, eqn2, eqn3], [x, y, z])
A = 
B = 
P_centre = linsolve(A,B)
Warning: Solution does not exist because the system is inconsistent.
P_centre = 
Can you please tell me where I am going wrong?
  8 件のコメント
Siddharth Behal
Siddharth Behal 2022 年 10 月 22 日
Thank you so much, Torsten. I really appreciate your help.
Siddharth Behal
Siddharth Behal 2022 年 10 月 22 日
Also, do you know how can I plot this arc? I just need the arc between three points instead of the circle

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

採用された回答

Matt J
Matt J 2022 年 10 月 21 日
編集済み: Matt J 2022 年 10 月 21 日
I would suggest this FEX download,
x_i = [0,5,20];
y_i = [0,0,0];
z_i = [20,5,0];
P1 = [x_i(1),y_i(1),z_i(1)];
P2 = [x_i(2),y_i(2),z_i(2)];
P3 = [x_i(3),y_i(3),z_i(3)];
pfit=planarFit([P1;P2;P3]');
xy=pfit.R(:,2:3)'*pfit.XYZ;
cfit=circularFit(xy);
C=cfit.sample(0:360);
XYZ =num2cell( pfit.R(:,2)*C{1} + pfit.R(:,3)*C{2} + pfit.normal'*pfit.distance ,2);
scatter3(x_i,y_i,z_i,'filled','r','SizeData',50);
line(XYZ{:}); axis equal
xlabel x, ylabel y, zlabel z
  2 件のコメント
Siddharth Behal
Siddharth Behal 2022 年 10 月 22 日
Is there a way to draw only the arc between three points instead of the entire circle?
Matt J
Matt J 2022 年 10 月 22 日
編集済み: Matt J 2022 年 10 月 22 日
pfit=planarFit([P1;P2;P3]');
xy=pfit.R(:,2:3)'*pfit.XYZ;
cfit=circularFit(xy);
xy=xy-cfit.center';
t1=atan2d(xy(2,1),xy(1,1));
t2=atan2d(xy(2,3),xy(1,3));
C=cell2mat(cfit.sample(linspace(t1,t2)));
XYZ = num2cell( pfit.R(:,2)*C(1,:) + pfit.R(:,3)*C(2,:) + pfit.normal'*pfit.distance ,2);
scatter3(x_i,y_i,z_i,'filled','r','SizeData',50);
line(XYZ{:}); axis equal
xlabel x, ylabel y, zlabel z

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by