RE: RE: Generating Two Unit Orthogonal Vectors to a 3D Vector
- To: mathgroup at smc.vnet.net
- Subject: [mg36383] RE: [mg36359] RE: [mg36352] Generating Two Unit Orthogonal Vectors to a 3D Vector
- From: "DrBob" <drbob at bigfoot.com>
- Date: Wed, 4 Sep 2002 02:56:39 -0400 (EDT)
- Reply-to: <drbob at bigfoot.com>
- Sender: owner-wri-mathgroup at wolfram.com
This works just as well: OrthogonalUnitVectors[v:{_, _, _}] := (#1/Sqrt[#1 . #1] & ) /@ NullSpace[{v, {0, 0, 0}, {0, 0, 0}}] The Dot product will never be zero, since NullSpace will not return an answer with zero vectors even if v={0,0,0}. Bobby Treat -----Original Message----- From: Ingolf Dahl [mailto:f9aid at fy.chalmers.se] To: mathgroup at smc.vnet.net Subject: [mg36383] [mg36359] RE: [mg36352] Generating Two Unit Orthogonal Vectors to a 3D Vector David, Here is my solution, using NullSpace: OrthogonalUnitVectors[v:{_,_,_}]:=(Needs["LinearAlgebra`Orthogonalizatio n`"] ; 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. Best regards Ingolf Dahl f9aid at fy.chalmers.se Chalmers University Sweden -----Original Message----- From: David Park [mailto:djmp at earthlink.net] To: mathgroup at smc.vnet.net Subject: [mg36383] [mg36359] [mg36352] Generating Two Unit Orthogonal Vectors to a 3D Vector There are many cases in graphics, and otherwise, where it is useful to obtain two orthogonal unit vectors to a given vector. I know a number of ways to do it, but they all seem to be slightly inelegant. I thought I would pose the problem to MathGroup. Who has the most elegant Mathematica routine... OrthogonalUnitVectors::usage = "OrthogonalUnitVectors[v:{_,_,_}] will return two unit vectors orthogonal to each other and to v." You can assume that v is nonzero. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/