# Orthogonal Vector using Projection

I have the following two vectors:

$$\vec a = \begin{pmatrix}0.0\\ 6.0\\ 0.0\end{pmatrix}$$

$$\vec b = \begin{pmatrix}-4.0\\ 8.0\\ 0.0\end{pmatrix}$$

These are just examples, I am looking to solve this issue for all 3D vectors.

So with these vectors, I want to create a vector $$\vec c$$ that is Orthogonal to $$\vec a$$ and intersects with $$\vec b$$ by getting the correct points on $$\vec a$$ and $$\vec b$$.

Basically, in this scenario I want the resulting vector: $$\vec c = (-3.0, 0, 0)^\top$$.

Right now, I can easily get the point on $$\vec a$$ (projb), by projecting $$\vec b$$ onto a and then scaling down based on the magnitude of the vectors. However, I have no idea how to get the second point.

The following picture will hopefully illustrate my issue ($$\vec a$$: blue, $$\vec b$$: green): I am not sure how to create a vector that is orthogonal to a, and even if I could create an infinite orthogonal vector to a from the point I would still need to figure out the intersection point / magnitude of my new vector.

Hopefully some of you can help me out.

• What do you mean by "intersects with" in this context? – Alex Provost May 8 '16 at 16:05
• So you are searching for some scalar multiple of the orthogonal component $b-(b\cdot a)a$? – John Wayland Bales May 8 '16 at 16:26
• Oops! Unless $a$ is a unit vector that needs to be $b-\frac{b\cdot a}{a\cdot a}\,a$. – John Wayland Bales May 8 '16 at 16:34
• @JohnWaylandBales my calculations might be off, but using that formula I get -4, 0, 0 and not -3, 0, 0. – Simon Langhoff May 8 '16 at 18:07
• @SimonLanghoff I think you mean to say that the vector $a+c$ intersects the line spanned by $b$. – Alex Provost May 8 '16 at 20:32

## 1 Answer

If ??? of your picture is the destination of your vector $\vec c$ and it starts at the $\vec a$ I think you got the equations that $$\vec a+\vec c=\lambda \vec b \tag{1}$$ wiht $\lambda \in \mathbb R$ for the "intersection" and $$\vec a\cdot \vec c=0\tag{2}$$ from the orthogonality.

Then you can insert the concrete values into (1) $$\vec c=\lambda \begin{pmatrix}-4\\8\\0\end{pmatrix}-\begin{pmatrix}0\\6\\0\end{pmatrix}$$ From (2) and $\vec a = \begin{pmatrix}0\\6\\0\end{pmatrix}$you can see that $c_y=0$ This means $$6-\lambda8=0$$ $$\lambda =\frac34$$ and thus $$\vec c=\frac34\begin{pmatrix}-4\\8\\0\end{pmatrix}-\begin{pmatrix}0\\6\\0\end{pmatrix}=\begin{pmatrix}-3\\0\\0\end{pmatrix}$$

Edit

If you want to solve it in algorithm you can use $$\lambda=\frac{\vec a^2}{\vec a\cdot \vec b}$$ to get the lambda then use $\vec c=\lambda\vec b -\vec a$ You can use this for your program.

• Thank you for the answer. I am to solve this using a programming language (Pawn) which does not have a solver or any library useful for equations. Is it possible to solve without "solving for x"? If that makes any sense?. – Simon Langhoff May 8 '16 at 17:54
• @SimonLanghoff See Edit – Matthias May 8 '16 at 20:00