# Rotating 3D coordinates to 2D plane

3dgeometryrotationsvectors

I'm trying to solve this problem but I'm stuck;

I have 2 coordinates, in 3D, say $$C_1 = (x_1,y_1,z_1)$$ and $$C_2 = (x_2,y_2,z_2)$$.
Now I'd like to transpose these to a 2-dimensional plane, but instead of just saying $$z_1=z_2=0$$. I'd like to keep the distance and relation between these two coordinates.

So, I figured for that I should transpose the coordinates, such that $$C_1$$ is at $$(0,0,0)$$, and $$C_2 = (x_2-x_1, y_2-y_1, z_2-z_2-z_1)$$, and then rotate with a rotation matrix $$R$$.

But can someone help me with how to find the right rotation matrix if I want the lenght on the x-axis?

Let the vectors be denoted by $$v_1$$ and $$v_2$$ (my preference :)).

1. Get the cross product of the two: $$c = v_1 \times v_2$$
$$c$$ is orthogonal to both $$v_1$$ and $$v_2$$.

2. Get the angle between $$c$$ and $$k=(0,0,1)$$: $$\cos\theta = \frac{c\cdot k}{|c|}$$

3. Rotate both vectors about $$a = c \times k$$ by $$\theta$$ using Rodrigues' rotation formula
You have to normalize $$a$$ to get a unit vector before applying it to the formula: $$a' = a/|a|$$.

The pair of resulting vectors is one instance of possible rotations and both are perpendicular to $$k$$ ($$z$$-axis).

The rotation matrix can be obtained from Rotation matrix from axis and angle