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 comentario

Steven Lord
Steven Lord el 24 de Oct. de 2019
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.

Iniciar sesión para comentar.

Respuestas (1)

David Hill
David Hill el 24 de Oct. de 2019
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

Categorías

Más información sobre Get Started with MATLAB en Centro de ayuda y File Exchange.

Preguntada:

el 24 de Oct. de 2019

Comentada:

el 24 de Oct. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by