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

• To: mathgroup at smc.vnet.net
• Subject: [mg36359] RE: [mg36352] Generating Two Unit Orthogonal Vectors to a 3D Vector
• From: "Ingolf Dahl" <f9aid at fy.chalmers.se>
• Date: Tue, 3 Sep 2002 01:41:01 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```David,
Here is my solution, using NullSpace:

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.
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: [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