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): Drawing to illustrate the points I need to calculate

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.

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

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}$$


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.

  • $\begingroup$ 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?. $\endgroup$ – Simon Langhoff May 8 '16 at 17:54
  • $\begingroup$ @SimonLanghoff See Edit $\endgroup$ – Matthias May 8 '16 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.