How to find perpendicular vector to another vector?

How do I find a vector perpendicular to a vector like this: $$3\mathbf{i}+4\mathbf{j}-2\mathbf{k}?$$ Could anyone explain this to me, please?

I have a solution to this when I have $3\mathbf{i}+4\mathbf{j}$, but could not solve if I have $3$ components...

When I googled, I saw the direct solution but did not find a process or method to follow. Kindly let me know the way to do it. Thanks.

-
Choose two coordinates, switch them, add a minus sign, and complete with zeroes. For example: choosing i and j might yield 4i-3j, choosing i and k might yield 2i+3k, and choosing j and k might yield 2j+4k. –  Did Apr 26 '12 at 19:09
@Didier thanks for letting me know but as you told,we have got 3 solutions. 4i-3j,2i+3k,2j+4k its not single vector.I need a vector something like ai+bj+ck which is perpendicular to other vector.sorry but I Just started to learn vectors. –  niko Apr 26 '12 at 19:15
$2j+4k=0i+2j+4k$. –  David Mitra Apr 26 '12 at 19:19
Pick any vector not colinear to your vector and take their cross product. –  N. S. Apr 26 '12 at 20:26
Not to de-rail the thread, but does anyone know why this particular question has over 15k views? –  Jesse Madnick Feb 27 '13 at 7:51

There exists an infinite number of vectors in 3 dimension that are perpendicular to a fixed one. They should only satisfy the following formula: $$(3\mathbf{i}+4\mathbf{j}-2\mathbf{k}) \cdot v=0$$

For finding all of them, just choose 2 perpendicular vectors, like $v_1=(4\mathbf{i}-3\mathbf{j})$ and $v_2=(2\mathbf{i}+3\mathbf{k})$ and any linear combination of them is also perpendicular to the original vector: $$v=((4a+2b)\mathbf{i}-3a\mathbf{j}+3b\mathbf{k}) \hspace{10 mm} a,b \in \mathbb{R}$$

-
What is this kind of notation called? I have never seen a vector being defined like $(3i + 4j - 2k)$. The notation I've seen so far would be $\left(\begin{array}{c}3\\4\\2\end{array}\right)$, therefore I do not really understand your answer. :( –  Niklas R Oct 30 '12 at 22:20
There are many possible notation, I choose to use the same notation of the question, but other choice are good as well. $i$,$j$,$k$ refers to vectors $(1,0,0)$, $(0,1,0)$ and $(0,0,1)$, so it is basically the same thing after you do vector-scalar multiplication. –  carlop Dec 14 '12 at 13:49
@NiklasR Since you wanted a name, $\mathbf{i}$, $\mathbf{j}$, and $\mathbf{k}$ are called the (classical) Hamiltonian Quaternions. –  Alexander Gruber Jul 5 at 20:23

You just need to find any vector $v \neq 0$ such that $v \cdot (3\mathbf{i}+4\mathbf{j}-2\mathbf{k}) = 0$.

There is no unique solution, any one will do. To save typing, let $p = 3\mathbf{i}+4\mathbf{j}-2\mathbf{k}$.

Pick a vector $x$, that is not on the line through the origin and $p$. Take $x = 3\mathbf{i}$, for example.

Construct a vector perpendicular to $p$ in the following way: Find a value of $t$ so that $(v+t p) \cdot p = 0$. Then the vector $(v+t p)$ will be perpendicular to $v$.

In my example, $(v+t p) = (3 + 3 t)\mathbf{i}+4 t \mathbf{j}-2t\mathbf{k}$, and $(v+t p) \cdot p = 9 + 29 t$. By choosing $t=-\frac{9}{29}$, the vector $v+t p$ is now perpendicular to $p$.

-

A related problem is to construct an algorithm that finds a non-zero perpendicular vector without branching. If the input vector is N = (a,b,c), then you could always choose T = (c,c,-a-b) but T will be zero if N=(-1,1,0). You could always check to see if T is zero, and then choose T = (-b-c,a,a) if it is, but this requires a test and branch. I can't see how to do this without the test and branch.

-

A suggested solution without a branch could be: Construct an array of 2 vector elements in the following way:

arr[0] = (c,c,-a-b) arr[1] = (-b-c, a,a)
int selectIndex = ((c != 0) && (-a != b)) // this is not a branch
perpendicularVector = arr[selectIndex]


If (c, c, -a-b) is zero, selectIndex is 1 and the other vector will be selected.

-

The dot product of two perpendicular vectors are always 0 so if you (ai+bj+ck)*(di+ej+fk)=0 you can solve for the different variables. If you have one vector than the infinite amount of perpendicular vectors will form a plane that is perpendicular to the original vector. If you know one or two of the coordinates of the desired perpendicular line than you can find the corresponding vector(s) on that plane.

-

Remember: There exist infinite vector in 3 dimension that are perpendicular to a fixed one. Now, Let v ≠0 be the vector whose is xi+yj+zk. So , v is perpendicular to the vector 3i+4j-2k. Therefore, v.(3i+4j−2k)=0. (xi+yj+zk). (3i+4j−2k)=0 3x+4y-2z=0 ……………….(1) where i.i =j.j=k.k=1.

Now, there are three unknown variable such x, y and z in (1). You can choose any two variable whatever you like. Let y=2 and z=1,
then x=-2 from (1),

One of the vector is (-2i+2j+k). Similarly, you can choose one of two variables from (1) , then find the third variable. So, you can find infinite perpendicular vectors to the vector 3i+4j-2k.

-

All vectors perpendicular to the given vector form a plane .................. If v1 and v2 are perpendicular to the given vector v = 3*i +4*j -2*k ............ Then the dot products v.v1 =0 and v.v2 = 0 ...................... If v1 = 2*i -j + k and v2 = 2*i +j +5*k .................. Then a plane formed by any vector v3 = a*v1 +b*v2 ; where 'a' and 'b' are scalars, will be normal to the given vector 'v' . ..........

-

Take cross product with any vector. You will get one such vector.

-

Definition of the Dot Product:

$\vec{a} \cdot \vec{b}$ = ( $a_{1} , a_{2}$ ) $\cdot$ ( $b_{1} , b_{2}$ ) = $a_{1}b_{1} + a_{2}b_{2}$

also known as the scalar product or inner product

$\mathbf{\vec{a} \cdot \vec{b}}$ is a one "number" answer

Orthogonal Vectors:

Two vectors are orthogonal (perpendicular) if and only if $\ \mathbf{\vec{a} \cdot \vec{b} = 0}$ in other words... two vectors are perpendicular if their DOT PRODUCT is ZERO

Example:

Let

$\vec{a}$ = ( 8 , -4 )

that is:

$a_{1}$ = 8

$a_{2}$ = -4

Find a vector $\mathbf{\vec{r}}$ that is perpendicular to $\mathbf{\vec{a}}$:

$\vec{r}$ = (x, y);

that is:

$b_{1} = x$

$b_{2} = y$

$\vec{a} \cdot \vec{r} = 8x + (-4y) = 0 \Rightarrow$

$\Rightarrow 8x - 4y = 0 \Rightarrow$

$8(1) - 4(2) = 0 \Rightarrow \mathbf{\vec{r} = (1, 2)} \Rightarrow$ one solution

$8(2) - 4(4) = 0 \Rightarrow \mathbf{\vec{r} = (2, 4)} \Rightarrow$ other solution

$8(-1) - 4(-2) = 0 \Rightarrow \mathbf{\vec{r} = (-1, -2)} \Rightarrow$ other solution

... as Rebecca said: << Keep in mind there will be an infinite number of perpendicular vectors >> ... Here the pdf source

-
Just so you know, you can make a dot in MathJax with \cdot and subscripts with _. For more info, check out meta.math.stackexchange.com/questions/5020/…. –  Bye_World Jul 5 at 19:46
@Bye_World, Thanks a lot! :-) –  Riccardo Jul 5 at 19:49

wcochran, I was thinking about exactly the same question, i.e.:

Is it possible to construct a non-zero vector perpendicular to a given one in 3D without using conditional statements (like if/else) or their analogs (like sign(expr))?

The answer is NO, IT IS NOT POSSIBLE!

This seams rather strange, since in 2D the answer to a similar question is yes, and it is a commonly used procedure. Here is an idea for why it is not possible in 3D ...

Using cross product (discussed above) it is easy to construct a vector W perpendicular to any given ones U and V, as W=UxV. The problem with this procedure is that if U=cV, then W=0. So, the problem reduces to constructing a vector V that is not a scalar multiple of U. If we assume that all vectors under consideration have length 1, then we are working on the surface of a sphere.

Thus, an equivalent question is: Is there a continuous (~avoids conditionals) mapping, V=f(U), of a sphere into itself such that neither f(U) nor -f(U) have a fixed point?
Here, a fixed point corresponds to a situation when V=+-U, and hence W=UxV=0.

I am sure the answer to the last question is NO, and it follows from "Brouwer fixed-point theorem". Unfortunately, I cannot make the connection precise at the moment.

-

I wanted to post this code here because I think it is very useful and helps answer the question.

The function works by taking any normalize vector and it swaps the components around. After the swap, it test (thanks to good old dot-product) the newly swapped vector against the function argument to see if is as close to perpendicular as possible(you can change these values).

If the swapped vector is not perpendicular, the function repeats the step until it founds one.

/**
* This function accepts a normalized vector and returns a normalized vector perpendicular to it
* @param normalized_vector
* @return
*/
glm::vec3 getPerp(const glm::vec3& normalized_vector){
glm::vec3 perp = glm::vec3 (normalized_vector.y, -normalized_vector.x, normalized_vector.z );

float dot = glm::dot(perp , normalized_vector);

//Remember the properties of the dot product between two normalized vectors
//  0 = perpendicular
//  1 = parallel

//Check if this pseudo perp is perpendicular,
if(dot > 0.0f && dot < 0.2f){
//if so return it
return perp;
}

perp = glm::vec3 (normalized_vector.x, -normalized_vector.z, normalized_vector.y );
dot = glm::dot(perp , normalized_vector);
//Check if this pseudo perp is perpendicular,
if(dot > 0.0f && dot < 0.2f){
//if so return it
return perp;
}

perp = glm::vec3 (-normalized_vector.z, normalized_vector.y, normalized_vector.x );
dot = glm::dot(perp , normalized_vector);
//Check if this pseudo perp is perpendicular,
if(dot > 0.0f && dot < 0.2f){
//if so return it
return perp;
}

return glm::vec3(1,1,1);

}

-
Welcome to MSE! In its current form, this does not provide an answer. Can you actually run the code and provide an answer derived from it? Regards –  Amzoti Aug 29 '13 at 3:51
Also, can you state which language the code is in? –  Douglas S. Stones Sep 5 '13 at 0:50