how can i draw circle in 3D space with 3 point ?

50 views (last 30 days)
Dear all
I need to draw a circle in space with 3 points that I have.
For example in the picture below I need to through the circle among the purple orange and the yellow dots.
and the arrays are :
% for yellow dots :
x=[0.0614989006404664,0.113882215391292,0.150982198682794,0.168720920205744];
y=[0.00968012746750092,0.0348743496847940,0.0721490692945351,0.117011183107267]
z=[0.00433547467220984,-0.0182991382514783,-0.0513287453937180,-0.0902019922333220]
% for purple dots :
x=[0.0538953885999417,0.100380017854628,0.133603344329503,0.149651163313763]
y=[0.0181936243771012,0.0397661500353233,0.0724936983973233,0.112238051664588]
z=[-0.0140617255229237,-0.0345013279495237,-0.0642363653195066,-0.0992745656450756]
% for orange dots :
x=[0.0601617429784619,0.112244770523508,0.149580182011997,0.167771471007159];
y=[-0.00252268954107996,0.0216775496992773,0.0583666486260463,0.102963217155185]
z=[-0.0134985732822516,-0.0353846070611784,-0.0679669312855640,-0.106648973683681]
  1 Comment
shahin hashemi
shahin hashemi on 17 Feb 2018
and i should mention that i consider that it is possible to draw the circle through these dots cause the radius is constant and it is 12.5e-3

Sign in to comment.

Accepted Answer

Roger Stafford
Roger Stafford on 18 Feb 2018
Let your three points be P1=[x1;y1;z1], P2=[x2;y2;z2], P3=[x3;y3;z3], and call the as yet unknown center P0 = [x0;y0;z0]. I will give you a partial solution which leaves some work for you to do.
v1 = cross(P2-P1,P3-P1);
v1 = v1/norm(v1); %Unit vector orthogonal to plane of 3 points
The center, P0, must satisfy these three equations:
dot(P0-P1,v1) = 0
dot(P0-(p2+P1)/2,P2-P1) = 0
dot(P0-(p3+P1)/2,P3-P1) = 0
Your task is to express these equations in a standard linear form A*P0=B where A is 3-by-3 and B is 3-by-1, so that matlab can solve for P0 as P0 = A\B. That gives you the center.
Next do this
v2 = P1-P0;
R = norm(v2);
v2 = v2/R;
v3 = cross(v2,v1);
v3 = v3/norm(v3);
Now you have mutually orthogonal unit vectors v2 and v3 both parallel to the plane of the desired circle. Finally do this:
t = linspace(0,2*pi);
P = repmat(P0,1,numel(t)) + R*(v2*cos(t) + v3*sin(t));
plot3(P(1,:),P(2,:),P(3,:),'y-') % This should give you your circle
If you want only an arc of a circle, change the linspace limits appropriately.
  2 Comments
Ahmad Adee
Ahmad Adee on 14 Jul 2018
How do you linearize these equations? Can you share the code? I have the equation but can separate the x0, y0 and z0 terms.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by