Finding a vector that points towards a coordinate

447 Views Asked by At

How to find a vector $v$ with a magnitude $m$ that starts at $(0, 0, 0)$ (or any other arbitrary coordinate) and points towards a coordinate $(x, y, z)$. For example, let $m$ be 100, and the coordinate be $(200, 0, 0)$. $v$ would then be $(100, 0, 0)$.

2

There are 2 best solutions below

0
On BEST ANSWER

You may first find the vector which points from your initial, call it $C_0$, coordinate in the direction of the desired, call it $C_d$, coordinate by subtracting: $C_d-C_0$. Then you can divide this vector by its magnitude (assuming you haven’t just created the 0-vector) and multiply the result by your desired magnitude $m$.

0
On

Define the target point as ${\bf P}$ and call ${\bf O}$ the origin. The vector going from ${\bf O}$ to ${\bf P}$ is

$$ {\bf u} = {\bf P} - {\bf O} $$

To make it of norm $m$, just define

$$ {\bf v} = m\frac{{\bf u}}{|{\bf u}|} = m\frac{{\bf P} - {\bf O}}{|{\bf P} - {\bf O}|} $$