Let's say I have three points in regular 3D space.
$$ p_1 = (x_1, y_1, z_1) $$ And so on. I know the coordinates of these three points.
Now imagine a fourth point. I am trying to find the cartesian coordinates of this point.
This is what I know:
- The distance between point 1 and point 4. In other words, $R_{14}$.
- The angle formed between points 1, 2, and 4. In other words, $\theta_{124}$.
- The dihedral angle between the plane formed by atoms {1, 2, 3} and the plane formed by atoms {1, 2, 4}.
I can relatively easily solve a simpler version, where I just make up a new coordinate space, and plot point 1 at the origin, use point 2 to define an axis (say the x-axis) and use point 3 to define a plane (for example the x-y plane). By doing that it is simple to find the cartesian coordinates of point 4 in this new artificial space. But I am interested in finding the cartesian coordinates of point 4 to a real origin, which does not coincide with any of the first 3 points. I am not sure how to do this. However, I think maybe the "fake" x, y, and z vector from the the artificial space's origin to point 4 (in other words, the vector from point 1 to point 4) may still be useful, I am just not sure how to use it in conjunction with the other information I know. It would be easy if the space created by the four points had its axis pointing in the same directions as the "real" space, but this is usually not the case, usually it's rotated in some way.
If you would like more context, I am trying to make a python script which will take a Z-matrix https://en.wikipedia.org/wiki/Z-matrix_(chemistry) and turn it back into regular cartesian coordinates. In other words, turn the 3rd table from that wikipedia article into the second.
I am reasonably comfortable with math (although my vector calc is rusty, as you can probably guess), but the only programming I know is a bit of python so please nothing too high level in terms of computing. But thank you for reading (and hopefully answering!)
Edit: I'm not 100% sure I am able to solve it yet, but I believe a combination of this: https://en.wikipedia.org/wiki/Kabsch_algorithm and some of the information given here: How to think about the change-of-coordinates matrix $P_{\mathcal{C}\leftarrow\mathcal{B}}$
Will allow me to do what I want.