# How to find the cartesian coordinates of a point from its relationship to other points?

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.

## 1 Answer

How is your linear algebra (specifically a basic graduate level course that defined/emphasized abstract vector spaces over fields, linear operators between vector spaces, matrix representation of linear operators given a basis, etc.)?

Good news is your problem is not very hard to solve, I recommend taking a look at "Linear Algebra" by Friedberg, Insel, Spence (often just referred to as Friedberg), gives a very clear exposition on the subject. What you're looking for is covered in sec. 2.5 "change of coordinate matrix" but you may need to review some of the earlier material for this to make sense. Basically, you can "change" coordinates by spinning all the axes (this corresponds to a certain linear operator or function applied to the space), solve the problem (i.e find your points "easy" coordinates), and then apply the inverse of the linear operator to turn the axes exactly back as they were and look at your solutions "new" or "original" coordinates.

• My only linear algebra is the intro undergrad course. I am a grad student but in computational chemistry, coming from a chem background. I will look at this book if I can find it, thanks – iammax Aug 10 '16 at 1:23