How can I plot tilt ellipse with known c1(x1,y1), c2(x2,y2), and one point on the ellipse(p,q)?
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I am tyring to get data tilted ellipse using known 2 foci ( c1(x1,y1), c2(x2,y2) ) and one point on the ellipse(p,q).
I need to compare two individual tilt ellipse; thus, I need parametric form of each ellipse (e.g, E1(x,y) matrix and E2(x,y) matrix)
Here is my trial code,
clear;
clc;
point = [50, 150]; %p, q
c1 = [-5,0]; %c1
c2 = [-34,-20]; %c2
xc = (c1(1)+c2(1))/2; %center_x
yc = (c1(2)+c2(2))/2; %center_y
c = [xc, yc];
r = norm(c1-point)+norm(c2-point); %constant distance
tilt_angle = atan((c1(2)-c2(2))/(c1(1)-c2(1)))*180/pi; %tilt angle
a = r/2; %2a=r
b = sqrt(a^2-(norm(c1-c))^2); %b^2=a^2-c^2
% x = x0 + a*cos(t)*cos(theta) - b*sin(t)*sin(theta);
% y = y0 + b*sin(t)*cos(theta) - a*cos(t)*sin(theta);
t = [0:0.01:2*pi];
x = xc+a.*cos(t)-b.*sin(t).*sin(tilt_angle);
y = yc+b.*sin(t)-a.*cos(t).*sin(tilt_angle);
plot(x, y, '-'); hold on;
plot(point(1),point(2),'xr'); hold on;
plot(c1(1),c1(2),'xg'); hold on;
plot(c2(1),c2(2),'xb'); hold on;
the result is here, but ellipse does not exactly include the point
and also, when I change one foci( c2[-10,0] ), the figure looks much stranger as follows:
Threoretically, the tilt ellipse should include whatever values of foci are. Could you guys help me to get exact tilat ellipse for these known values?
Thank you so much!
Best,
Ted
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vehicle Scenarios 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!