Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.fr>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Angle between two vectors
Date: Sat, 29 Dec 2007 09:16:29 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 37
Message-ID: <fl539d$np9$1@fred.mathworks.com>
References: <ef5ce9c.-1@webcrossing.raydaftYaTP> <fjj9nj$fia$1@fred.mathworks.com> <fjk0tg$jli$1@fred.mathworks.com> <fl377q$4ip$1@fred.mathworks.com> <fl3moi$pvc$1@fred.mathworks.com> <fl3nhq$3tc$1@fred.mathworks.com> <fl3r7p$5nt$1@fred.mathworks.com> <fl4nc4$47i$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.fr>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1198919789 24361 172.30.248.37 (29 Dec 2007 09:16:29 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 29 Dec 2007 09:16:29 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:443791


"baris kazar" <mbkazar.nospam@gmail.com> wrote in message
<fl4nc4$47i$1@fred.mathworks.com>...

> 
> However,
> you can define it locally wrt a point/vector as long as 
> they are on a plane by defining from which side you are 
> looking at.

That's a good way. Pick a side.

That's easy. 

1. Select two arbitrary vectors in the set, e.g., the first
(U) and the second (V) vectors, assumming they are all unit
vectors. Normalize them if they aren't.

2. Next compute the cross product N = U x V. This gives you
a normal vector N pointing ONE side of the plane.

3. Take a cross product W = N x U. Now you have {U,W} which
is a orthonormal basis vectors of the plane. In other word,
Span(U,V) = Span(U,W), <U,W>=0, |U|=1, |W|=1.

4. Compute the angle as of any vector Z (in the plane as
following):

theta = atan2(<W.Z>,<U.Z>)  % <- Do not change U or W

This gives you ONE consistent way to define angle (only for
vectors belong to the plane).

PS: In a more abstract way, you can also accomplish steps
1->3 by using Gram-Smidth orthogonalization, or QR (help qr).

Bruno