필터 지우기
필터 지우기

How can I rotate an ellipse randomly

조회 수: 3 (최근 30일)
Emma
Emma 2021년 3월 3일
편집: Walter Roberson 2021년 3월 3일
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
Walter Roberson
Walter Roberson 2021년 3월 3일
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 2021년 3월 3일
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?

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2021년 3월 3일
See my attached demos. Adapt as needed.

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by