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!