S.O.S. Mathematics CyberBoard

Your Resource for mathematics help on the web!
It is currently Thu, 20 Jun 2013 04:52:50 UTC

All times are UTC [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Sign of angle between vectors
PostPosted: Fri, 6 Jan 2012 20:00:26 UTC 
Offline
Senior Member
User avatar

Joined: Mon, 2 May 2005 19:58:46 UTC
Posts: 86
Say I have a 2D vector \vec{AB} connecting two points A and B. The midpoint of the vector, M, is connected to another point C, which is not collinear with A and B.

If I rotate \vec{AB} by an angle \theta, where \theta<\pi, then \vec{AB} has the same direction as \vec{MC}. (Similarly, if I rotate \vec{AB} in the other direction by an angle (2\pi-\theta) then \vec{AB} has the same direction as \vec{MC}.)

I can figure out \theta using the dot product of \vec{MC} and \vec{MB}. My question is, how do I figure out if \theta is in the clockwise or counterclockwise direction?


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Fri, 6 Jan 2012 21:44:53 UTC 
Online
Moderator
User avatar

Joined: Wed, 30 Mar 2005 04:25:14 UTC
Posts: 12172
Location: Austin, TX
DannyBoy wrote:
Say I have a 2D vector \vec{AB} connecting two points A and B. The midpoint of the vector, M, is connected to another point C, which is not collinear with A and B.

If I rotate \vec{AB} by an angle \theta, where \theta<\pi, then \vec{AB} has the same direction as \vec{MC}. (Similarly, if I rotate \vec{AB} in the other direction by an angle (2\pi-\theta) then \vec{AB} has the same direction as \vec{MC}.)

I can figure out \theta using the dot product of \vec{MC} and \vec{MB}. My question is, how do I figure out if \theta is in the clockwise or counterclockwise direction?


A priori you cannot tell, because it will depend on an orientation, which you haven't chosen.

If you are using the standard orientation, you should be able to convince yourself that you STILL cannot tell because cosine is an even function, so the dot product doesn't care if it's positive or negative.

_________________
(\ /)
(O.o)
(> <)
This is Bunny. Copy Bunny into your signature to help him on his way to world domination


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Fri, 6 Jan 2012 21:52:24 UTC 
Offline
Senior Member
User avatar

Joined: Mon, 2 May 2005 19:58:46 UTC
Posts: 86
Thanks for the reply, Shadow! I guess that's my point: the dot product cannot tell me the direction, so how do I find out?


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Fri, 6 Jan 2012 22:06:36 UTC 
Online
Moderator
User avatar

Joined: Wed, 30 Mar 2005 04:25:14 UTC
Posts: 12172
Location: Austin, TX
DannyBoy wrote:
Thanks for the reply, Shadow! I guess that's my point: the dot product cannot tell me the direction, so how do I find out?


If all you know is the dot product, you cannot find out. Even if you know one of the vectors you cannot figure that out, because all the dot product does is tell you how much of one vector is in the direction of the other, so you can get the direction of the other vector if you know one and you know their dot product, but that's about it.

To see this note if one vector has components (a,b) known and the other has components (x,y) unknown and you have their dot product is c, then all you know is ax+by=c, i.e. what line your other vector lies on.

_________________
(\ /)
(O.o)
(> <)
This is Bunny. Copy Bunny into your signature to help him on his way to world domination


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Fri, 6 Jan 2012 22:24:03 UTC 
Offline
Senior Member
User avatar

Joined: Mon, 2 May 2005 19:58:46 UTC
Posts: 86
Thanks again for the reply, Shadow. Perhaps I'm not articulating myself very well: I know both vectors.

In short, if I have two vectors, how do I determine which direction to rotate one of these vectors such that it points the same way as the other vector providing I rotate it through the smallest angle possible?


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Fri, 6 Jan 2012 22:32:22 UTC 
Online
Moderator
User avatar

Joined: Wed, 30 Mar 2005 04:25:14 UTC
Posts: 12172
Location: Austin, TX
DannyBoy wrote:
Thanks again for the reply, Shadow. Perhaps I'm not articulating myself very well: I know both vectors.

In short, if I have two vectors, how do I determine which direction to rotate one of these vectors such that it points the same way as the other vector providing I rotate it through the smallest angle possible?


Oh, that's easy. Just look at the orientation between them, if C is to the right of the line through A and B, then go clockwise, if not go counterclockwise, draw a picture of both situations and you should be able to see why this is.

_________________
(\ /)
(O.o)
(> <)
This is Bunny. Copy Bunny into your signature to help him on his way to world domination


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Mon, 9 Jan 2012 15:47:37 UTC 
Offline
Senior Member
User avatar

Joined: Mon, 2 May 2005 19:58:46 UTC
Posts: 86
But how do I do it mathematically? I have around half a million cases to consider, so would prefer not to draw pictures for each! :D


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Mon, 9 Jan 2012 19:34:27 UTC 
Offline
Senior Member
User avatar

Joined: Mon, 2 May 2005 19:58:46 UTC
Posts: 86
Okay, here's my attempted solution. Assuming two 2D vectors, \vec{a} and \vec{b}, the direction of smallest necessary rotation needed for \vec{a} to align with \vec{b} can be determined as follows.

\alpha=\arctan2(y_b,x_b)-\arctan2(y_a,x_a)

Counterclockwise if \pi>\alpha>0 or \alpha<-\pi
Clockwise if -\pi<\alpha<0 or \alpha>\pi
Neither if \alpha=0
Either if \alpha=\pi or \alpha=-\pi


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Mon, 9 Jan 2012 20:15:20 UTC 
Online
Moderator
User avatar

Joined: Wed, 30 Mar 2005 04:25:14 UTC
Posts: 12172
Location: Austin, TX
DannyBoy wrote:
But how do I do it mathematically? I have around half a million cases to consider, so would prefer not to draw pictures for each! :D


You said you know the vectors, look at their coordinates.

_________________
(\ /)
(O.o)
(> <)
This is Bunny. Copy Bunny into your signature to help him on his way to world domination


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Mon, 9 Jan 2012 20:18:58 UTC 
Offline
Senior Member
User avatar

Joined: Mon, 2 May 2005 19:58:46 UTC
Posts: 86
Is there a more efficient way of determining the direction from the coordinates than my solution, which seems rather clunky?


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Mon, 9 Jan 2012 20:47:48 UTC 
Online
Moderator
User avatar

Joined: Wed, 30 Mar 2005 04:25:14 UTC
Posts: 12172
Location: Austin, TX
Probably, but I personally don't see why, you asked how to do it, and that works, so why rock the boat?

_________________
(\ /)
(O.o)
(> <)
This is Bunny. Copy Bunny into your signature to help him on his way to world domination


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Mon, 9 Jan 2012 20:56:00 UTC 
Offline
Senior Member
User avatar

Joined: Mon, 2 May 2005 19:58:46 UTC
Posts: 86
Because I have to perform the operations around half a million times in an R program, so the more efficient the solution, the faster my code will run.


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Tue, 10 Jan 2012 14:18:43 UTC 
Online
Moderator
User avatar

Joined: Mon, 29 Dec 2008 17:49:32 UTC
Posts: 6068
Location: 127.0.0.1, ::1 (avatar courtesy of UDN)
DannyBoy wrote:
Because I have to perform the operations around half a million times in an R program, so the more efficient the solution, the faster my code will run.


You need only the sign of x_1y_2-x_2y_1, where (x_1,y_1)=\overrightarrow{AB},\quad (x_2,y_2)=\overrightarrow{MC}. However, note the subtraction of possibly nearly equal quantity.

_________________
\begin{aligned}
Spin(1)&=O(1)=\mathbb{Z}/2&\quad&\text{and}\\
Spin(2)&=U(1)=SO(2)&&\text{are obvious}\\
Spin(3)&=Sp(1)=SU(2)&&\text{by }q\mapsto(\mathop{\mathrm{Im}}\mathbb{H}\ni p\mapsto qp\bar{q})\\
Spin(4)&=Sp(1)\times Sp(1)&&\text{by }(q_1,q_2)\mapsto(\mathbb{H}\ni p\mapsto q_1p\bar{q_2})\\
Spin(5)&=Sp(2)&&\text{by }\mathbb{HP}^1\cong S^4_{round}\hookrightarrow\mathbb{R}^5\\
Spin(6)&=SU(4)&&\text{by the irrep }\Lambda_+\mathbb{C}^4
\end{aligned}


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Tue, 10 Jan 2012 14:47:25 UTC 
Offline
Senior Member
User avatar

Joined: Mon, 2 May 2005 19:58:46 UTC
Posts: 86
Wow, very efficient! Thanks, outermeasure! So, your approach looks like the determinant of \left[\begin{array}{cc}
x_1 & y_1 \\
x_2 & y_2 \\
\end{array}\right]. Could you explain why it works or point me in the direction of a webpage?


Top
 Profile  
 
 Post subject: Re: Sign of angle between vectors
PostPosted: Tue, 10 Jan 2012 15:29:50 UTC 
Online
Moderator
User avatar

Joined: Mon, 29 Dec 2008 17:49:32 UTC
Posts: 6068
Location: 127.0.0.1, ::1 (avatar courtesy of UDN)
DannyBoy wrote:
Wow, very efficient! Thanks, outermeasure! So, your approach looks like the determinant of \left[\begin{array}{cc}
x_1 & y_1 \\
x_2 & y_2 \\
\end{array}\right]. Could you explain why it works or point me in the direction of a webpage?


You should know the signed area of triangle OPQ is \dfrac{1}{2}\det\begin{pmatrix}x_P & y_P\\ x_Q & y_Q\end{pmatrix} (assuming usual orientation).

_________________
\begin{aligned}
Spin(1)&=O(1)=\mathbb{Z}/2&\quad&\text{and}\\
Spin(2)&=U(1)=SO(2)&&\text{are obvious}\\
Spin(3)&=Sp(1)=SU(2)&&\text{by }q\mapsto(\mathop{\mathrm{Im}}\mathbb{H}\ni p\mapsto qp\bar{q})\\
Spin(4)&=Sp(1)\times Sp(1)&&\text{by }(q_1,q_2)\mapsto(\mathbb{H}\ni p\mapsto q_1p\bar{q_2})\\
Spin(5)&=Sp(2)&&\text{by }\mathbb{HP}^1\cong S^4_{round}\hookrightarrow\mathbb{R}^5\\
Spin(6)&=SU(4)&&\text{by the irrep }\Lambda_+\mathbb{C}^4
\end{aligned}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Contact Us | S.O.S. Mathematics Homepage
Privacy Statement | Search the "old" CyberBoard

users online during the last hour
Powered by phpBB © 2001, 2005-2011 phpBB Group.
Copyright © 1999-2013 MathMedics, LLC. All rights reserved.
Math Medics, LLC. - P.O. Box 12395 - El Paso TX 79913 - USA