# Method to find a orthonormal basis with a vector of the basis with the same direction of a given vector

my question is how find a orthonormal basis {u,v,w} such that w has the same direction of vector a :

The method that I found is the following, but I'm not sure that it's right and I would like confirmation:

w = a / ||a||

Let t with the same components of w but with the minimal component of w setted to 1. Example if w = (3 ; 2 ; 7) then t = (3 ; 1 ; 7)

Thus:

u = (t x w) / ||(t x w)||

when x indicates the cross product.

and

v = w x u

It is right?

• Look up Gram-Schmidt Process
– robjohn
Sep 9, 2016 at 21:59
• There is nothing abstract about this question, so I have removed the abstract algebra tag. Sep 10, 2016 at 2:15

Since you are obviously talking about $\Bbb R^3$, that will work (assuming $a$ is not zero). Because the cross-product is perpendicular to both vectors in the product, $u$ is perpendicular to $w$ and $v$ is perpendicular to $u$ and $w$. $w$ and $u$ are normalized directly, and since they are perpendicular, their cross-product will also be normalized. That guarantees that $u, v, w$ form an orthonormal basis. As a bonus, by picking $v = w \times u$ instead of $u \times w$, you have even guaranteed that $(u, v, w)$ forms a right-handed axis system, but this is not needed to be orthonormal.
It is not necessary that $t$ be picked in this fashion. The same trick will work for any $t$ that is not a multiple of $a$.
However, note that this only works for $\Bbb R^3$, as the cross-product only exists in 3 dimensions. If you have vectors in a space of dimension 2, or of dimension of 4 or more, you will have to do something else. This is where the Gram-Schmidt process comes in: start by expanding $a$ into a full basis by picking other vectors not in the span of those picked already. When you have a full basis, apply the Gram-Schmidt process to convert this arbitrary basis into an orthonormal one. If you start the process with $a$, then the resulting orthonormal basis will include a vector parallel to $a$.
• You can simplify the method a little, and increase numerical stability by converting $w$ to $t$ by setting the smallest coordinate in $w$ to $0$, exchanging the places of the other two coordinates, and taking the opposite of the largest coordinate. For example, if $w = (x, y, z)$ and $|x| \ge |y| \ge |z|$, then you would set $t = (y, -x, 0)$. This $t$ is already perpendicular to $w$, so you don't need the first cross-product. You can just define $u = \frac{t}{\|t\|}$ and then calculate $v$ as per your post. Sep 10, 2016 at 14:11