How can I rotate a set of points by an angle around its origin?
22 ビュー (過去 30 日間)
古いコメントを表示
I have a set of data points that I would like to rotate around its origin by 45 degrees.
I already have the following code:
ITM = [sl.x sl.y]; %81x2 matrix
x_centre = sl.x(1); %rotate around its origin
y_centre = sl.y(1);
centre = transpose(repmat([x_centre; y_centre], 1, length(sl.x))); %transpose to get 81x2 matrix
theta = pi/4 %45 degrees
R = [cos(theta -sun(theta); sin(theta cos(theta)];
vo = R*(v - centre) + centre;
x_rotated = vo(1, :);
y_rotated = vo(2, :);
However, I get the error "incorrect dimensions for matrix multiplication".
Using '.*' doesn't solve the issue either.
How could I rotate these 81 points around its origin by 45 degrees?
0 件のコメント
採用された回答
Alan Stevens
2022 年 1 月 7 日
Do you mean like this?
ITM = [461400.0758 617474.3059
461400.8069 617475.4609
461400.8069 617475.4609
461402.3069 617477.6334
461402.9793 617478.8059
461402.9793 617478.8059
461404.8069 617481.0369
461404.8069 617483.4696
461405.5181 617484.3059
461405.7293 617484.8059
461407.3069 617487.1909
461408.1 617488.3059
461408.3069 617488.6369
461409.3069 617489.7196
461410.5885 617491.8059
461410.5885 617491.8059
461412.3069 617493.1334
461413.2552 617494.8059
461413.2552 617494.8059
461414.3069 617495.5946
461416.0758 617497.8059
461417.1689 617499.3059
461417.6109 617500.3059
461418.5758 617501.8059
461419.3069 617503.1369
461419.4793 617504.3059
461420.3069 617506.1564
461420.8069 617506.8576
461421.6977 617507.8059
461422.8069 617509.6334
461422.85 617509.8059
461424.3069 617511.4696
461424.3069 617511.4696
461426.6418 617513.8059
461427.3069 617514.8369
461427.8069 617516.1909
461428.4477 617517.8059
461428.725 617518.3059
461429.8069 617519.7484
461430.499 617521.3059
461431.4793 617522.3059
461431.4793 617522.3059
461432.8069 617523.4369
461434.3069 617525.8317
461434.8069 617526.4709
461435.2758 617526.8059
461436.3069 617527.5753
461437.3069 617528.4214
461440.1431 617529.8059
461440.1431 617529.8059
461441.4793 617530.3059
461444.0375 617532.3059
461444.0375 617532.3059
461444.9793 617532.8059
461446.225 617534.3059
461448.1913 617536.3059
461448.1913 617536.3059
461449.8069 617538.0423
461449.8069 617538.0423
461451.7473 617539.8059
461452.5913 617540.8059
461453.7243 617542.3059
461453.7243 617542.3059
461455.2552 617543.3059
461456.2389 617544.3059
461458.1689 617545.8059
461458.6273 617546.8059
461459.6689 617548.8059
461460.1801 617549.8059
461460.8069 617551.4438
461461.5181 617552.8059
461461.9758 617554.3059
461462.3758 617555.3059
461462.8931 617556.3059
461463.6418 617557.3059
461465.3069 617559.0214
461465.3069 617559.0214
461466.1518 617559.8059
461468.3069 617561.3446
461469.4758 617562.8059
461469.7293 617563.3059];
x_centre = ITM(1,1);
y_centre = ITM(1,2);
x = ITM(:,1)-x_centre;
y = ITM(:,2)-y_centre;
v = [x y];
theta = pi/4; %45 degrees
R = [cos(theta) -sin(theta); sin(theta) cos(theta)]; %%%%%%%%%%%%%%%
vo = v*R;
x_rotated = vo(:,1)+x_centre;
y_rotated = vo(:,2)+y_centre;
plot(ITM(:,1),ITM(:,2),'.',x_rotated,y_rotated,'o')
xlabel('x'),ylabel('y')
legend('initial','rotated')
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!