I wish to compute the angles between 4 atoms from the distances between them. I can use the law of cosines to work out the two simple triangles, but I am struggling to find a (hopefully elegant) solution for the dihedral.
The ASCII art below describes my preferred system: triangle ABC is on the XZ plane (Y=0), with B on the origin and C on the +Z axis. Triangle BCD rotates D around the Z axis, so x and y coordinates for D are the unknown values (but my current goal is the dihedral angle, not the coordinates):
|
| D
\ | /
\ |/
\ C
\ I
\I
--------B---------- x
/|\
/ | \
A | \
| \
z y
My goal now is to get the dihedral angle rotation for ABCD from the distances AB, BC, CD, AC, BD and AD.
I expect there will be a chirality issue (2 points on the circle traced by D about the Z axis with the same AD distance), but I believe I can solve this with other constraints.
Helpful direction, advice or implementation detail you may have will be very much appreciated.
Edit: I have implemented the algorithm referenced in the comments in Biopython version 1.80/1.81, specifically the distance_to_internal_coordinates() routine. I was unable to resolve the chirality issue and require this data as an input.