Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How can I determine a vector if I knew the angle between two
Date: Thu, 1 Dec 2011 04:10:09 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 18
Message-ID: <jb6un1$t6f$1@newscl01ah.mathworks.com>
References: <jb6onn$cch$1@newscl01ah.mathworks.com> <e1475487-6bfd-4ed0-81da-c576db6f35b0@q9g2000yqe.googlegroups.com> <jb6rho$kbe$1@newscl01ah.mathworks.com> <jb6thh$pu3$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1322712609 29903 172.30.248.45 (1 Dec 2011 04:10:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 1 Dec 2011 04:10:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:751042

"Roger Stafford" wrote in message <jb6thh$pu3$1@newscl01ah.mathworks.com>...
>   There will be two solutions, v1 and v2:
> 
>   a = atan2(u(2),u(1)); % Angle w.r. x-axis
>   v1 = [cos(a+theta),sin(a+theta)];  % Rotate plus theta
>   v2 = [cos(a-theta),sin(a-theta)];  % Rotate minus theta
> 
> Both v1 and v2 will be unit vectors.
> 
> Roger Stafford
- - - - - - - - -
  The computation may be a little faster if you do it this way:

 c = cos(theta); s = sin(theta); n = norm(u);
 v1 = [u(1)*c-u(2)*s,u(2)*c+u(1)*s]/n;
 v2 = [u(1)*c+u(2)*s,u(2)*c-u(1)*s]/n;

Roger Stafford