Hi, I have dots spread like a tube in a 3d space. I want to fit a circle to this data (the data is attached). The plane that the circle should be in is:
S1=[-15.8,8.6,1.3]; S2=[-10.5,10.3,-3.3]; S3=[-15.2,8.9,1.6]; normal = cross(S1-S2, S1-S3); A = normal(1); B = normal(2); C = normal(3); D = dot(normal,S1);
This is what I was trying to do:
plot3(n1,n2,n3,'*') %The dots
hold on a2=[mean(n1),mean(n2),mean(n3)]; %Center of the dots
plot3(a2(1),a2(2),a2(3),'*','color','g') a3=dist(a2,[n1;n2;n3]); %calculate the radius
t = linspace(0,2*pi,40); x=(mean(a3).*sin(t)+mean(n1)); y=(mean(a3).*cos(t)+mean(n2)); z = (A * x + B * y - D)/(-C); plot3(x,y,z,'*','color','r')
But I can't set the circle right in place (it is grater than what it should be). could you help?
Best Answer