Finding closest circle to a general circle
Mostrar comentarios más antiguos
Hi,
For my research, I have to calculate three circular orbits. One original orbit and two other orbits. I have to find the most closest circle to the original circle. From visualization, it can be seen that the red circle is the closest one to original (green) cirle. But I am looking for analytical way to make conclusions on circles. Because sometimes circles become to closer to original circle, where visualization works not fine, in this case I have to decide by looking at analytical result. But I am in a doubt how to calculate analytically. I have used some methods which gives different unrelated results.
Would be nice if someone helps me to solve it:))
Green - original (3rd circle)
Red - 1st circle
Blue - 2nd circle
(2D view)

From pictures may look like ellipses but orginally they are inclined circles! Figures are provided from different angles. 2D view also provided
2 comentarios
KSSV
el 26 de Dic. de 2022
How did you plot the circles?
Mirzobek Malikov
el 26 de Dic. de 2022
Respuesta aceptada
Más respuestas (1)
You could try to fit a plane trought each circle, comput the normal of that plane. And then determine the angle between the normal of each circle and the reference circle. See below for a demonstration of the concept.
First we need a bit of code to generate a circle in 3D:
% create a circle
tht = linspace(0,2*pi,100);
Cirle_Grid = [cos(tht); sin(tht); 0*tht];
% define some rotation functions so that we can orient our circle in 3D
% space
RotX = @(t) [1 0 0; 0 cos(t) -sin(t); 0 sin(t) cos(t)];
RotY = @(t) [cos(t) 0 sin(t); 0 1 0;-sin(t) 0 cos(t)];
RotZ = @(t) [cos(t) -sin(t) 0; sin(t) cos(t) 0; 0 0 1];
% create some random oriented circles, we choose the data such that circle
% 2 will be the closest and we have a third circle which is fully random
C1x = rand;
C1y = rand;
C1z = rand;
C2x = C1x + 0.1*rand;
C2y = C1y + 0.1*rand;
C2z = C1z + 0.1*rand;
Circ1 = RotZ(C1x) * RotY(C1y) * RotX(C1z) * Cirle_Grid;
Circ2 = RotZ(C2x) * RotY(C2y) * RotX(C2z) * Cirle_Grid;
Circ3 = RotZ(rand) * RotY(rand) * RotX(rand) * Cirle_Grid;
% make a plot to see if evrything is working
figure
hold on
plot3(Circ1(1,:),Circ1(2,:),Circ1(3,:),'b')
plot3(Circ2(1,:),Circ2(2,:),Circ2(3,:),'r')
plot3(Circ3(1,:),Circ3(2,:),Circ3(3,:),'g')
hold off
grid on
view(3)
Now lets look for the circle closest to a reference circle, here let's take Circ1 as the reference circle.
% first find the normals to the circles, i included the function below
[N1,C1] = CircleNormal(Circ1);
[N2,C2] = CircleNormal(Circ2);
[N3,C3] = CircleNormal(Circ3);
% plot the circles and the normal's
figure
hold on
plot3(Circ1(1,:),Circ1(2,:),Circ1(3,:),'b')
plot3(Circ2(1,:),Circ2(2,:),Circ2(3,:),'r')
plot3(Circ3(1,:),Circ3(2,:),Circ3(3,:),'g')
quiver3(C1(1),C1(2),C1(3),N1(1),N1(2),N1(3),'b')
quiver3(C2(1),C2(2),C2(3),N2(1),N2(2),N2(3),'r')
quiver3(C3(1),C3(2),C3(3),N3(1),N3(2),N3(3),'g')
hold off
grid on
view(3)
% now determine the angles between the normals
Ang_21 = atan2(norm(cross(N2,N1)), dot(N2,N1))
Ang_31 = atan2(norm(cross(N3,N1)), dot(N3,N1))
And indeed, as we can see Ang_21 is smaller en hence is the circel which is "closest" to our reference circle :)
function [N,Center] = CircleNormal(Grid)
Center = mean(Grid,2);
Grid = Grid - repmat(Center, 1, size(Grid,2));
[U,S,V] = svd(Grid',0);
N = -1/V(end,end)*V(:,end);
end
6 comentarios
You can use this FEX download to fit a plane, and subsequently an ellipse or circle, to the points:
Mirzobek Malikov
el 26 de Dic. de 2022
Matt J
el 26 de Dic. de 2022
It is not clear from your post whether you know the radii, center, and plane of the orbits. If you did know them, there are equations that can be solved to determine the smallest and largest distances between points along the orbits, assuming that's what you're trying to find.
@Mirzobek Malikov, i didn't try to fit a circle in my answer. I only tried to fit a plane trought the existing points, i started my answer with the creation of random circles in 3d because you didn't provide some example data. Nevertheless the second part of the answer show the concept of finding the normals of the planes and determining the angles with respect to a reference circle to find the "nearest". Is the approach suitable for your data?
If the appraoch is not suitable, there are off course alternatieve approaches, but then it would be best to provide some example data.
Mirzobek Malikov
el 26 de Dic. de 2022
Mirzobek Malikov
el 26 de Dic. de 2022
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


