Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!news-2.dfn.de!news.dfn.de!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: someone <newsboost@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Matlab - transformation matrix - what is wrong?
Date: Thu, 24 Nov 2011 14:16:58 +0100
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <jalg4b$d3v$1@dont-email.me>
References: <ja3d4u$o8j$1@dont-email.me> <ja3hvg$2to$1@newscl01ah.mathworks.com> <ja55if$3uf$1@dont-email.me> <ja64e7$m7e$1@newscl01ah.mathworks.com> <jaivg8$ogp$1@dont-email.me> <jaj6jg$p6e$1@newscl01ah.mathworks.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 24 Nov 2011 13:16:59 +0000 (UTC)
Injection-Info: mx04.eternal-september.org; posting-host="VLhVb73eEkxjtAk2RWgeNA";
	logging-data="13439"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19gs9ojRD1lg29oSbNG5FLeIFr15rc6SeA="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
In-Reply-To: <jaj6jg$p6e$1@newscl01ah.mathworks.com>
Cancel-Lock: sha1:NcXXvNTobhjXF3r7FgntpDgMdG8=
Xref: news.mathworks.com comp.soft-sys.matlab:750331

On 2011-11-23 17:22, Matt J wrote:
> someone <newsboost@gmail.com> wrote in message
> <jaivg8$ogp$1@dont-email.me>...
>>
>> Yep, I think it works now using this code:
>>
>>
>> crossProdVec = [1;0;0];
>>
>> % don't want to cross xvec with itself (it gives [0;0;0])
>> if all(xvec == crossProdVec)
>> yvec = [0 1 0];
>> zvec = [0 0 1];
>> else
>> yvec = cross(xvec,crossProdVec);
>> zvec = cross(xvec,yvec);
>> end
> ================
>
> No. It will still fail if xvec=[-1;0;0] . Here's what you probably want:
>
>
> xvec = xvec./norm(xvec);
>
> SmallTolerance=1e-6; %You choose this.
>
> if norm(xvec(2:3))<=SmallTolerance %xvec is highly paralllel to x-axis
>
> crossProdVec = [0;1;0];
>
> else
> crossProdVec = [1;0;0];
>
> end
>
> yvec = cross(xvec,crossProdVec);
> zvec = cross(xvec,yvec);

Ah, of course!

Thank you very much...

A shame if Roger Stafford doesn't see my other linear algebra post about 
understanding different aspects of the rotational matrix, because I was 
so slow at answering... I think he has a really good understanding of 
this, which I lack :-)