# Handling vectors for double-bond graphics

I'm working on a small molecular graphics tool for visualising ball-and-stick style molecules. I'm having trouble handling the linear algebra to position the two bonds in the double bonds. My linear algebra is, unfortunately, very weak. I can follow notation but struggle with working my own way through logical algebra.

If I'm overcomplicating this significantly then I'd appreciate some guidance on how so. Here is my working so far:

I currently have the atomic coordinates of each atom. All of the above atoms are in a plane due to the $sp^2$ nature of atom $i$, though the orientation of the plane is arbitrary.

$\textbf i$, $\textbf j$ and $\textbf k$ are atomic coordinates and $\textbf a$ and $\textbf b$ are vectors between them.

The orientation of the double bond must mean that both of the lines in the double bond are positioned in the plane, and I have quantified the plane as:

$\textbf{a} \times \textbf{b} \cdot (\textbf{r} - \textbf{r}_0) = 0$

where $\textbf r$ is any vector in the plane, and $\textbf{r}_0$ is any other point in the plane.

I can also say that the points which I am looking for on each atom make vectors with the centre of respective atoms at $90 ^\text{o}$ to $\textbf b$, and that the radius at which these points are positioned is constrained to a constant value (and therefore so is the length of said vector). If we call this vector $\textbf l$ we therefore have:

$(\textbf{a} \times \textbf{b}) \cdot (\textbf{l} - \textbf{i}) = 0$

$| \textbf{l} | = \text{const}.$

$\textbf{l} \cdot \textbf{b} = 0$

where $\textbf{a}$, $\textbf{b}$ and $\text{i}$ are all things which are numerically available to me.

I feel as though, based upon geometrical constraints, these algebraic relationships are enough to find only the 4 points which I want. But my amateur self has no idea how to do that.

• I guess there should be one more constrain that would rotate a multiple bond plane along $\mathbf b$ so that projection of that plane to a computer screen is always maximal (so that visibility of multiple bonds is rotation-agnostic). Don't ask me how to implement it, it's just a suggestion:) – andselisk Oct 10 '17 at 23:13
• Yeah I thought of that as an option but discarded it for now, in favour of always having the double bond in the $sp^2$ plane. – obackhouse Oct 10 '17 at 23:20