Re: Generating Two Unit Orthogonal Vectors to a 3D Vector

*To*: mathgroup at smc.vnet.net*Subject*: [mg36387] Re: Generating Two Unit Orthogonal Vectors to a 3D Vector*From*: Tom Burton <tburton at brahea.com>*Date*: Wed, 4 Sep 2002 02:56:45 -0400 (EDT)*References*: <al1i1d$kra$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

On 9/2/02 10:36 PM, in article al1i1d$kra$1 at smc.vnet.net, "Ingolf Dahl" <f9aid at fy.chalmers.se> wrote: > OrthogonalUnitVectors[v:{_,_,_}]:=(Needs["LinearAlgebra`Orthogonalization`"] > ; > Map[LinearAlgebra`Orthogonalization`Normalize, > NullSpace[{v,{0,0,0},{0,0,0}}]]) > > One problem with any solution is that it should never be possible to obtain > the two output vectors as continuous functions of the input vector, since > that would be equivalent to the combing of a hedgehog in a vortexfree way. NullSpace is fast, but LinearAlgebra`Orthogonalization`Normalize is slow. So if you care about speed, perhaps #/Sqrt[#.#]& is better. I don't know hedgehogs, but if I visualize a fur-covered ball, then I can see as how a continuous solution is not possible everywhere. In that case, I might like to control the discontinuity. NullSpace create a curve on discontinuities on the unit sphere (a vortex curve, if you will). Try, e.g., ContourPlot[{v, w} = NullSpace[{{y, .3, x}, {0, 0, 0}, {0, 0, 0}}]; v[[3]], {x, -1, 1}, {y, -1, 1}, PlotPoints -> 100] It's not obvious to me where this curve is going to be. A nice feature of the following simple scheme, triad[u_, r_:{1, 0, 0}] := Module[{v = Cross[u, r]}, #/Sqrt[# . #] & /@ {u, v, Cross[u, v]}] is that you know that the two points of discontinuity are where r and -r cross the unit sphere. triad is slow, but if you commit to a particular r and then evaluate and simplify, FullSimplify[trial[{u,v,w}] the resulting expression evaluates pretty fast for specific numerical {u,v,w}. Tom Burton