Any ellipse can be uniquely defined by five parameters i.e. center x0 and y0, semi-major aixs length a, semi minor axis length b, and orientation angle theta. I have parameters x0, y0, a, b, and theta. How can I exactly draw the ellipse?
Asked
Active
Viewed 206 times
1 Answers
-1
Some researches are necessary before to ask this kind of question. Mainly if the question was asked too much time.
You can do something like this :
Let (x1,y1) and (x2,y2) be the coordinates of the two vertices of the ellipse's major axis, and let e be its eccentricity.
a = 1/2*sqrt((x2-x1)^2+(y2-y1)^2);
b = a*sqrt(1-e^2);
t = linspace(0,2*pi);
X = a*cos(t);
Y = b*sin(t);
w = atan2(y2-y1,x2-x1);
x = (x1+x2)/2 + X*cos(w) - Y*sin(w);
y = (y1+y2)/2 + X*sin(w) + Y*cos(w):
plot(x,y,'y-')
axis equal
I don't have time to test it, but it should work. Next time, please read this section : How do I ask a good question
-
1Why answer if you yourself admit that this has been asked many times? – Suever Jun 21 '16 at 13:32
-
@Suever To help him even if I said that this question has been asked many times. Hopefully he will search more next time ^^ – Essex Jun 21 '16 at 13:34
-
1@Andromedae93 however, that is not how Stackoverflow works! if you find a duplicate, mark it as duplicate, so we dont have a lot of the same thing around – Ander Biguri Jun 21 '16 at 13:36
-
@AnderBiguri Ok sorry ^^ – Essex Jun 21 '16 at 13:38
-
Set -1 is really ugly when someone gives the answer .. Yes it's a duplicate, but set negative point is not cool – Essex Jun 21 '16 at 13:53