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

33 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 :
% for purple dots :
% for orange dots :
  1 Comment
shahin hashemi
shahin hashemi on 17 Feb 2018
Edited: 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.
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)


Community Treasure Hunt

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

Start Hunting!

Translated by