# Computing a vector with geometrical constraints

(Large Version here)

$A$ and $B$ are vectors with the origin at $\mathcal O$, the red dot near the bottom. The short bright purple line segments perpendicular to vectors $A$ and $B$ have magnitude $w$. Two colored line segments are drawn from the ends of the purple line segments stemming from $A$ and $B$, parallel to vectors $A$ and $B$. These line segments intersect at the point highlighted by the green circle. I wish to find the magnitude of $v$, the vector stemming from the origin and ending at the intersection of the two colored line segments.

I understand that the direction of $v$ must be

$$\frac{A}{||A||} + \frac{B}{||B||}$$

But I am having a very hard time finding the correct magnitude of $v$. I understand that the magnitude of $v$ should approach infinity as the angle between $A$ and $B$ reaches $0$.

## Note:

Ideally, this is done with vector operations on $A, B$, and $w$ as I am writing some software to compute $v$ given $A$ and $B$.

Let $2\theta$ be the angle between the vectors. Then the length of the two black segments from the origin to the colored lines is $w/\sin2\theta$. The magnitude of $v$ is therefore $$2{w\over\sin2\theta}\cos\theta={2w\cos\theta\over2\cos\theta\sin\theta}={w\over\sin\theta}.$$
You can compute $\sin\theta$ via either the dot product or (two-dimensional) cross product of $A$ and $B$ and various trigonometric identities. For instance, $A\cdot B=\|A\|\,\|B\|\cos2\theta$ and $\sin\theta=\sqrt{(1-\cos2\theta)/2}$.