I want to create an Arc path over 3 points in 3D space. I decided to draw a circle over them and then extract sector from p1 to p3 that passes through P2.
circle equation is:
fc = @(a) center + cos(a).*(q1-center) + sin(a).*(q2-center);
in 3D plane for each point on the circle!
What I have tried:
<pre>I use this code but it did not extract sector from p1-->p2-->p3 !
%Use n1 x n2 (where 'x' means the cross product) as the z-axis of the local CS
n12 = cross((p1 - center),(p2 - center));
n23 = cross((p3 - center),(p2 - center));
n13 = cross((p3 - center),(p1 - center));
n = [n12, n23, n13];
%sign(n(1,:)--> find tow Orthogonal vectors, means cross product==1,
%n./sign(n(1,:))--> make zero value column to NAN value!
n = n./sign(n(1,:));
idx = find(~all(isnan(n)),2);
n = n(:,idx(1));
n0 = n / norm(n);
% Vectors to describe the plane, idx--> The index specifier is one of the input points
q1 = P(:,idx(1));
%Use (n1 x n2) x n1 as the y-axis of the local CS.
q2 = center + cross(n0,(p1-center).').';
%% Function to compute circle point at given angle
fc = @(a) center + cos(a).*(q1-center) + sin(a).*(q2-center);
%% Get angles of the original points for the circle formula
a1 = angleFromPoint(center,p1,q1,q2);
a2 = angleFromPoint(center,p2,q1,q2);
a3 = angleFromPoint(center,p3,q1,q2);
function ang = angleFromPoint(center,p,q1,q2)
% Get the circle angle for point 'p'
comp = @(a,b) dot(a,b)/norm(b);
ang = atan( comp(p-center,q2-center)/comp(p-center,q1-center) );
end
[![the output is:][1]][1]
[1]: https:
as you see, the direction of sector in output is not true! the direction is the opposite! Can anyone guide me? thanks a lot!