Plot given points\lines\arcs in 3D

281 Views Asked by At

I need to plot 6 points in 3D by using Matlab. I used the command 'plot3' but I couldn't draw it.

  1. The coordinates of points $A,A,B,B',C,C',D$ are given.
  2. $AD,BD,CD$ are straight line segments
  3. $AA',BB',CC'$ are arcs with known radius $r$ and centers $c_{0},c_{1},c_{2}$.

enter image description here

The coordinates are

$A=(0,0,0), B=(400,0,0) C=(200,400,200), D=(226,137,62)$

$A'=(22,36,0), B'=(382,33,0), C'=(240,357,200)$

$c_{0}=(40,0,0), c_{1}=(360,0,0), c_{2}=(200,360,200), r=40$

1

There are 1 best solutions below

1
On

I suggest the following code:

A=[0;0;0];
B=[400;0;0];
C=[200;400;200];
D=[226;137;62];
Ap=[22;36;0];
Bp=[382;33;0];
Cp=[240;357;200];
c0=[40;0;0];
c1=[360;0;0];
c2=[200;360;200];
plot3(A(1,1),A(2,1),A(3,1),'r*');
hold on;
text(A(1,1),A(2,1),A(3,1),'A');
plot3(B(1,1),B(2,1),B(3,1),'r*');
text(B(1,1),B(2,1),B(3,1),'B');
plot3(C(1,1),C(2,1),C(3,1),'r*');
text(C(1,1),C(2,1),C(3,1),'C');
plot3(D(1,1),D(2,1),D(3,1),'r*');
text(D(1,1),D(2,1),D(3,1),'D');
plot3(Ap(1,1),Ap(2,1),Ap(3,1),'r*');
text(Ap(1,1),Ap(2,1),Ap(3,1),'Ap');
plot3(Bp(1,1),Bp(2,1),Bp(3,1),'r*');
text(Bp(1,1),Bp(2,1),Bp(3,1),'Bp');
plot3(Cp(1,1),Cp(2,1),Cp(3,1),'r*');
text(Cp(1,1),Cp(2,1),Cp(3,1),'Cp');
plot3(c0(1,1),c0(2,1),c0(3,1),'r*');
text(c0(1,1),c0(2,1),c0(3,1),'c0');
plot3(c1(1,1),c1(2,1),c1(3,1),'r*');
text(c1(1,1),c1(2,1),c1(3,1),'c1');
plot3(c2(1,1),c2(2,1),c2(3,1),'r*');
text(c2(1,1),c2(2,1),c2(3,1),'c2');
line([D(1,1) A(1,1)],[D(2,1) A(2,1)],[D(3,1) A(3,1)]);
line([D(1,1) B(1,1)],[D(2,1) B(2,1)],[D(3,1) B(3,1)]);
line([D(1,1) C(1,1)],[D(2,1) C(2,1)],[D(3,1) C(3,1)]);
az1=[atand((A(2,1)-c0(2,1))/(A(1,1)-c0(1,1))) atand((Ap(2,1)-c0(2,1))/(Ap(1,1)-c0(1,1)))];
[elat1,elon1]=ellipse1(c0(1,1),c0(2,1),[40 0],0,[az1(1,2)+180 az1(1,1)+180]);
plot(elat1,elon1,'c');
az2=[atand((B(2,1)-c1(2,1))/(B(1,1)-c1(1,1))) atand((Bp(2,1)-c1(2,1))/(Bp(1,1)-c1(1,1)))];
[elat2,elon2]=ellipse1(0,0,[40 0],0,[az2(1,1) az2(1,2)]);
plot(elat2+c1(1,1),elon2+c1(2,1),'c');
az3=[atand((C(2,1)-c2(2,1))/(C(1,1)-c2(1,1))) atand((Cp(2,1)-c2(2,1))/(Cp(1,1)-c2(1,1)))];
[elat3,elon3]=ellipse1(0,0,[40 0],0,[az3(1,1) az3(1,2)]);
plot3(elat3+c2(1,1),elon3+c2(2,1),c2(3,1)*ones(size(elat3,1),1),'c');  

But this kind of questions are better be asked in Stack Overflow