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
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
2019년 10월 24일
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 Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!