From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Matlab - transformation matrix - what is wrong?
Date: Fri, 18 Nov 2011 16:04:11 +0000 (UTC)
Organization: Xoran Technologies
Lines: 12
Message-ID: <ja5vlr$5g8$>
References: <ja3d4u$o8j$> <ja3hvg$2to$> <ja55if$3uf$> <ja5tit$r9n$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1321632251 5640 (18 Nov 2011 16:04:11 GMT)
NNTP-Posting-Date: Fri, 18 Nov 2011 16:04:11 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: comp.soft-sys.matlab:749781

"Matt J" wrote in message <ja5tit$r9n$>...
> If that's all you require, why not use two cross products, as follows
> if ~isequal(xvec,[1 0 0])

That should be

if norm(xvec,[1,0,0])

And, obviously, you may want to modify the code to account for the cases where xvec is very close to the x-axis, but doesn't coincide with it.