2d coordinate transformation specified origin matlab

8 ビュー (過去 30 日間)
Reuben Addison
Reuben Addison 2019 年 1 月 22 日
編集済み: Reuben Addison 2019 年 1 月 22 日
I asked this question sometime ago but i realised I did not ask it well due to me being new to matlab, I have a cordinate point I want to rotate 45 degrees clock wise but has a different origin other than 0,0. My origin is [start_x = 24.000;start_y = 16.000] and the cordinate I want to rotate about the origin is [target_x = 27.000,target_y = 16.000]
This what I have attempted so far.
theta = pi/4 ;
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];
p = [target_x target_y]';
New_Target = p * R;
Any Ideas?

採用された回答

Brian Hart
Brian Hart 2019 年 1 月 22 日
Hi Reuben,
You're almost there.
The basic idea is to subtract the rotation point value from the target point, so that you ARE rotating about the origin. Then do the rotation, and add the offset back.
target_x = 27.000;
target_y = 16.000;
start_x = 24.000;
start_y = 16.000;
p = [target_x target_y]';
rotPt = [start_x start_y]';
theta = pi/4 ;
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];
pTmp = p - rotPt;
pRotTmp = R * pTmp; %this is the proper multiplication order
pRot = pRotTmp + rotPt;
With this you get
pRot =
26.1213
18.1213
  1 件のコメント
Reuben Addison
Reuben Addison 2019 年 1 月 22 日
編集済み: Reuben Addison 2019 年 1 月 22 日
Thank you, this has been very helpful to me.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by