Circle projection to be ellipse on the ground
30 views (last 30 days)
Show older comments
Have an ellipse with r2 - major axis and r1 - minor axis, and tilted at some
degree. Above of the ellipse at some arbitrary height need to draw a circle with radius r2. Theoritically, if we incline the circle under
degree, it's projection to the ground plane must give us the ellipse.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1107575/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1107580/image.png)
For that, I have tried by using the rotate function. I have used it two time in the scretch. First, I inclined the circle around x-axis. Second, by saving the last properties of the first rotation, I have used them to rotate around z-axis. As a result, I have had kinda desirable but not well. I was working on the matter during this week, but still can't get a good result.
Here's my code:
% r1 and r2, minor and major axis of the ellipse
% xm and ym are mean values of the ellipse x and y parametres, so center of the circle and ellipse is the same
%
% circle draw
r = r2;
teta = linspace(0, 2*pi, 100);
x = r*cos(teta) + xm;
y = r*sin(teta) + ym;
z = 10*ones(1,length(x));
inclined_angle = acosd(r1/r2);
g = plot3(x, y, z);
grid on
xlabel('x')
ylabel('y')
zlabel('z')
rotate(g, [1 0 0], inclined_angle);
newx = g.XData;
newy = g.YData;
newz = g.ZData;
gg = plot3(newx, newy, newz);
rotate(gg, [0 0 1], alpha)
grid on
xlabel('x')
ylabel('y')
zlabel('z')
% ellipse
hold on
plot(xrange, yrange, 'color', [0.9290 0.6940 0.1250], 'LineWidth', 1.6);
Also,
xm = -0.769, ym = -0.148, r1 = 6.867, r2 = 10.073, alpha = 18.372, inclined_angle = 47.022
I have attached here some data of xrange and yrange for the ellipse in txt. files and my resultant plots.
3D:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1107505/image.png)
if we look from above, 2D: From this picture we can see tha projection of the circle is not exactly on our ellipse, on a bit different positions. I need to find the besst solution for it.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1107510/image.png)
I would be so appriciated if somebody help me to handle this issue.
9 Comments
Matt J
on 25 Aug 2022
To get xrange and yrange data, open the txt files, then copy it and past in Matlab command window by equalizing to variables xrange and yrange is recommended.
I have a better idea. Why don't you include xrange, yrange for us in a .mat file, which can be straightfowardly loaded in.
Answers (1)
Matt J
on 25 Aug 2022
Edited: Matt J
on 25 Aug 2022
The final position of the projected ellipse will depend on the z-coordinates that you have before the rotation.
z = 10*ones(1,length(x));
You don't seem to have accounted for that anywhere in your comparison.
See Also
Categories
Find more on Bartlett in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!