How to solve an equation involving euclidean norm operation? On page 3 of [Scalable, Versatile and Simple Constrained Graph Layout][1] it describes the equation:
$$|(\mathbf p-\mathbf r)-(\mathbf q+\mathbf r)|=d$$
Where $\mathbf p$ and $\mathbf q$ are known points, $\mathbf r$ is a vector, and $d$ is a known scalar.
It then goes on to solve for the $\mathbf r$ with smallest possible magnitude but I don't understand how.
 A: The value $|(\mathbf p-\mathbf r)-(\mathbf q+\mathbf r)|=d$ is the distance between the points $\mathbf p-\mathbf r$ and $\mathbf q+\mathbf r$.

As you see in the diagram, as $\mathbf r$ changes, the vector between those two points stays centered at the midpoint of the points $\mathbf p$ and $\mathbf q$. In the diagram I have shown two possible values of $\mathbf r$ that keep the value of $d$ constant. All the possible values of $\mathbf r$ that keep $d$ constant lie on the same circle.
You can then see that the $\mathbf r$ with the smallest magnitude is the one on the circle closest to point $\mathbf q$. That makes all four points $\mathbf {q+r}$, $\mathbf q$, $\mathbf p$, and $\mathbf {p-r}$ on the same line.
(There is another argument that keeps the size of $\mathbf r$ the same and finds when $d$ is the largest possible. I did not show that argument because although it is easier it is a bit off-point and is therefore less rigorous than the one I showed.)
Now we find the size of vector $\mathbf r$. The vector $(\mathbf p-\mathbf r)-(\mathbf q+\mathbf r)$ first goes from $\mathbf {q+r}$ to $\mathbf q$ (length $|\mathbf r|$), then to $\mathbf p$ (length $|\mathbf {p-q}|$), then finally to $\mathbf {p-r}$ (length $|\mathbf r|$ again). This total distance is $d$. Thus we get
$$d=|\mathbf r|+|\mathbf {p-q}|+|\mathbf r|$$
Solving for $|\mathbf r|$ we get
$$|\mathbf r|=\frac{d-|\mathbf {p-q}|}2$$
That gives us the desired length. Now we need the direction, which we see from the diagram is the same as the direction of the vector from point $\mathbf p$ to point $\mathbf q$, namely $\mathbf {q-p}$. To get the unit vector (of length $1$) in the same direction we divide that vector by its length, and get
$$\frac{\mathbf {q-p}}{|\mathbf {q-p}|}=\frac{\mathbf {q-p}}{|\mathbf {p-q}|}$$
We get the total vector $\mathbf r$ by multiplying its desired length by the unit vector in the desired direction, giving us
$$\mathbf r=\frac{d-|\mathbf {p-q}|}2\cdot \frac{\mathbf {q-p}}{|\mathbf {p-q}|}$$
$$=\frac{(d-|\mathbf {p-q}|)(\mathbf {q-p})}{2|\mathbf {p-q}|}$$
Note that this is almost the same expression that is in your linked document. I have the vector $\mathbf {q-p}$ in the numerator while the document has $\mathbf {pq}$. I'm not sure what the document means by that, but it probably means the vector from point $\mathbf p$ to point $\mathbf q$, which would agree with my expression. I would say that is bad notation in the document: it looks like it is multiplying two points, rather than taking the vector between them.
A: I think I have a handle on it.
|(p−r)−(q+r)|=d
|p−q−2r|=d

and iff we know that r is colinear we know we can factor
|p−q|−|2r|=d
|p−q|−2|r|=d

-2|r|=d−|p−q|
|r|=(d−|p−q|)/-2
|r|=(|p−q|−d)/2

and since we know r is defined in the direction of pq, which is (q-p)
we can multiply the magnitude by the normalized pq vector to find r
r=(|p−q|−d)/2 * pq/|p−q|
r=((|p−q|−d)pq)/(2*|p−q|)

This is however the negative of the answer shown in the paper.
I believe that is because they start with p-q but end with the vector q-p I think just to confused me.
If I start again with q-p then I get.
|(q+r)-(p−r)| = d
|q−p|+|2r| = d
|q−p|+2|r| = d
2|r| = d−|q−p|
|r| = (d−|q−p|)/2

r = (d−|q−p|)/2 * pq/|q-p|
r = ((d−|q−p|)pq)/(2|q-p|)

and since |q−p| is equivalent to |p-q|
r = ((d−|p-q|)pq)/(2|p-q|)

which is the result shown in the paper.
This make sense to me but depends entirely upon knowing r and pq are colinear so we can factor |r|.
