필터 지우기
필터 지우기

Rotating a Vector

조회 수: 107 (최근 30일)
A
A 2011년 7월 8일
댓글: James Tursa 2020년 4월 16일
Hello! I am wondering if anyone has an elegant way to rotate a vector by a specified degree.
For example, I have a vector that goes from (0,0) to (-1,-12). I want to rotate this vector by 5 degrees, incrementally until it reaches the x-axis.
Obviously this can be done from the math, but I wonder if anyone has a nicer way of doing this.
Thank you in advance!
Amina

채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 7월 8일
complex
vR = v*[1;1i]*exp(-1i*theta*pi/180)
  댓글 수: 2
A
A 2011년 7월 20일
Very nice, thanks!
The only problem that I am having is using vR as it is a 1x1 element and therefore not in usual vector form. Is there a way that I can mash this into that form?
James Tursa
James Tursa 2020년 4월 16일
real(vR) are the x components of the vectors, and imag(vR) are the y components of the vectors.

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Sean de Wolski
Sean de Wolski 2011년 7월 8일
Unless I'm missing something just use the rotation matrix:
v = [-1 -12];
theta = 5;
R = [cosd(theta) -sind(theta); sind(theta) cosd(theta)];
vR = v*R;
quiver(0,0,v(1),v(2))
hold on
quiver(0,0,vR(1),vR(2))
  댓글 수: 1
A
A 2011년 7월 20일
This works great! Thank you :)

댓글을 달려면 로그인하십시오.


Sayyed Ahmad Khadem
Sayyed Ahmad Khadem 2018년 12월 26일
Hi all,
I read this blog, and I have similar problem. I would be thankful to kindly give me some clues if you know.
Suppose that we have a vector field in y-x plane, let's consider following example:
Vector Field : Vf = [u, v]
u=x
v=y
Untitled.png
Now, I need to revolve the given vector field around the center of plot (i.e. [0 0]). Does anyone can provide some nice solution?
Thanks in advance,
  댓글 수: 1
Adam Danz
Adam Danz 2020년 4월 16일
You can use quiverRotate() from the file exchange.
You can flip the direction of the quiver arrows by using the quiver handle or by flipping the vector component prior to producing the quiver plot.
h = quiver(x,y,u,v);
quiverRotate(h)
% or
[Ur,Vr] = quiverRotate(u,v);
quiver(x,y,Ur,Vr)

댓글을 달려면 로그인하십시오.


wenhao li
wenhao li 2019년 1월 11일
Have you solved this problem? I met this problem, too.
  댓글 수: 1
Sayyed Ahmad Khadem
Sayyed Ahmad Khadem 2019년 1월 11일
Hi Wenhao,
No one has suggested a viable approach yet ! :-( I am still struggling !

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by