Finding the tangent line of an ellipse

12 views (last 30 days)
Destin Davis
Destin Davis on 10 Jun 2019
Commented: darova on 10 Jun 2019
I have to find the tangent line of an ellipse that I have written code for. The ellipse is parametrized, so I'm not sure how to write the code to find the tangent line. This is waht I have so far. What do you recommend I add to find the tangent line at the point (x(a),y(a))? Please respond as soon as possible.
function destin_ellipse(xRadius,yRadius)
c=sqrt(xRadius^2-yRadius^2);
theta = [0 : 0.01 : 2*pi]';
x = xRadius * cos(theta);
y = yRadius * sin(theta);
a=randi(300);
clf;
plot(x, y, 'LineWidth', 1);
hold on;
plot(x(a),y(a),'r.');
plot([-c x(a)],[0 y(a)],'g');
plot([c x(a)],[0 y(a)],'g');
plot(c,0,'r.');
plot(-c,0,'r.');
axis square;
grid on;
if xRadius>yRadius
xlim([-(xRadius+1), xRadius+1]); ylim([-(xRadius+1), xRadius+1])
else
xlim([-(xRadius+1), xRadius+1]);
ylim([-(yRadius+1), yRadius+1]);
end

Answers (1)

KSSV
KSSV on 10 Jun 2019
  4 Comments
Destin Davis
Destin Davis on 10 Jun 2019
Thank you so much. But with this derivative, how would I plot the tangent line at my point (x(a),y(a))?
darova
darova on 10 Jun 2019
What do you know about equation of a straight line?

Sign in to comment.

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!