How can I rotate an ellipse randomly

1 visualizzazione (ultimi 30 giorni)
Emma
Emma il 3 Mar 2021
This is what I have written so far
t = linspace(0,2*pi)
x = randn + randn*cos(t)
rng('shuffle');
y = randn + randn*sin(t);
plot(x,y)
I want to create random rotation for this ellipse each time I plot it while keeping this same code I have written so far.
  2 Commenti
Walter Roberson
Walter Roberson il 3 Mar 2021
Well, that would be possible, but it would be significantly easier if you could modify your existing code to something like
t = linspace(0,2*pi)
t = 1×100
0 0.0635 0.1269 0.1904 0.2539 0.3173 0.3808 0.4443 0.5077 0.5712 0.6347 0.6981 0.7616 0.8251 0.8885 0.9520 1.0155 1.0789 1.1424 1.2059 1.2693 1.3328 1.3963 1.4597 1.5232 1.5867 1.6501 1.7136 1.7771 1.8405
xc = randn();
x = xc + randn*cos(t)
x = 1×100
1.1575 1.1582 1.1604 1.1641 1.1693 1.1759 1.1839 1.1933 1.2041 1.2161 1.2294 1.2439 1.2595 1.2762 1.2939 1.3126 1.3321 1.3524 1.3734 1.3950 1.4172 1.4398 1.4627 1.4859 1.5093 1.5327 1.5561 1.5794 1.6025 1.6253
rng('shuffle');
yc = randn();
y = yc + randn*sin(t);
plot(x,y)
axis equal
If you do that then it becomes easier to rotate around its center, which would be at the known point (xc, yc). But if you insist that the existing code must be kept as-is, then it becomes necessary to estimate xc and yc
Emma
Emma il 3 Mar 2021
sorry one more question. I am very new to matlab so what exactly would you type to rotate randomly around (xc,yc)? And how do you inetgrate it into the code you wrote?

Accedi per commentare.

Risposte (1)

Image Analyst
Image Analyst il 3 Mar 2021
See my attached demos. Adapt as needed.

Categorie

Scopri di più su Animation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by