How can I find all points inside a ellipse
Mostrar comentarios más antiguos
I have the bounds of an ellipse in x- and y-coordinates. My end goal is to get a matrix of all x-values and a corresponding matrix of all y-values for the points in/out that ellipse. If possible, I would also like to color in the specified ellipse on a 2d plot. Does anyone know which commands/functions I can use to do this? Most of what I have seen simply confirms whether input values lie in/out an ellipse. Thank you!
such that a sample of the ellipse is represented as :
xCenter = 15;
yCenter = 10;
xRadius = 1.5;
yRadius = 80;
theta = 0 : 0.01 : 2*pi;
x = xRadius * cos(theta) + xCenter;
y = yRadius * sin(theta) + yCenter;
plot(x, y, 'LineWidth', 3);
1 comentario
Walter Roberson
el 29 de Dic. de 2017
There are an infinite number of points inside (or on) an ellipse. Even if you confine yourself to discrete x values, there would be an infinite number of y values, corresponding to the infinite density of the chord. To do anything useful, you need to either work with a symbolic formula or else discretize both x and y.
Respuesta aceptada
Más respuestas (2)
azdoud youssef
el 30 de Dic. de 2017
2 comentarios
Star Strider
el 30 de Dic. de 2017
That looks like it is doing what you want it to.
Waqar Khan
el 18 de Mzo. de 2021
@azdoud youssef how did you get the values from ellipse, Could you please share the code or give me suggestions.
Deepu Kumar
el 30 de Jul. de 2021
Editada: Deepu Kumar
el 30 de Jul. de 2021
0 votos
I think this is what you were asking.
In place of xCenter and yCenter, you can choose what ever the values that you want.
Similarly, the limits of xRadius and yRadius is of your choice.
xCenter = 0;
yCenter = 0;
xRadius = 1.41631:-(1.41631)/100:0;
yRadius = 0.53:-(0.53)/100:0;
theta = 0 : (2*pi)/100 : 2*pi;
for i=1:length(xRadius)
xx=xRadius(i);
yy=yRadius(i);
for j=1:length(yRadius)
x(i,j) = xx * cos(theta(j)) + xCenter;
y(i,j) = yy * sin(theta(j)) + yCenter;
end
end
plot(x, y, 'LineWidth', 3);
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!