Rotating one vector about another

Write a function named getRotatedPoint which receives two vectors and one scalar as input. The two vectors represent the x-y coordinates of two points and the scalar represents a rotation angle. The function must return the x-y coordinates of the first point after it is rotated around the second point by the rotation angle (in degrees) passed to the function.

1 件のコメント

Steven Lord
Steven Lord 2019 年 10 月 24 日
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.

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

回答 (1 件)

David Hill
David Hill 2019 年 10 月 24 日

0 投票

function P = getRotatedPoint(A,B,r)
C=A-B;
p=norm(C);
if C(1)<0
c=atand(C(2)/C(1))+180+r;
else
c=atand(C(2)/C(1))+r;
end
P=[p*cosd(c),p*sind(c)]+B;
end

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

質問済み:

2019 年 10 月 24 日

コメント済み:

2019 年 10 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by