How to create rotation matrix in 3D space?

In a 3d space $$(x,y,z)$$ where $$y$$ is the height, I have a plane which I constructed from 2 angles (creating a normal vector).

For example:

$$\alpha = -\pi, \beta = \frac{-\pi}{2}$$

To calculate the normal vector, I use:

$$\left(\begin{matrix} \cos(\alpha)\cos(\beta) \\ \sin(\beta) \\ \sin(\alpha)\cos(\beta) \\ \end{matrix}\right)$$

to get

$$\left(\begin{matrix} -0.6 \\ 0.8 \\ 0 \\ \end{matrix}\right)$$

I get the plane

$$e: 0 = -0.6x + 0.8y + 0z$$

A second plane is given

$$f: 0 = z$$

With what I have, can a calculate a rotation matrix of $$e$$ to $$f$$? If not, what is wrong with my approach?

My goal is to find the coordinates of any point $$P$$ of $$e$$ on $$f$$.

I of course found the Wikipedia page of Rotation matrix and other answers here, but I'm unable to construct the matrix. I'm missing some intermediate steps of understanding.

$$\newcommand {\vv} {\mathbf v} \newcommand {\nv} {\mathbf n} \newcommand {\uv} {\mathbf u} \newcommand {\wv} {\mathbf w}$$ The main problem is that there is not just one rotation of $$\Bbb R^3$$ that takes the first plane to the second. Suppose you had such a rotation, $$R$$, and followed it by another rotation $$T$$ that rotates in the second plane (spinning around its normal vector by, say, 30 degrees). Composing those two rotations to get $$S = T \circ$$ would give you a different rotation from the first plane to the second.

But typically in a question like this, what you want is a rotation from the first plane (I"m going to call that $$P_1$$, with normal vector $$\nv_1$$) to the second ($$P_2$$, normal vector $$\nv_2$$) with the additional property that the rotation doesn't move the line of intersection between the two planes.

That's not so hard to construct, surprisingly.

1. Let $$\vv = \nv_1 \times \nv_2 / \|\nv_1 \times \nv_2 \|$$; that's one of the two unit vectors in the intersection $$P_1 \times P_2$$.

2. Let $$\wv = \vv \times \nv_2$$; that's a unit vector lying in the second plane, perpendicular to $$\vv$$. So $$\vv, \nv_2, \wv$$ is an orthonormal basis for 3-space.

3. Let $$\uv = \vv \times \nv_1$$; that's a unit vector in the first plane, perp. to $$\vv$$. So $$\nv, \nv_1, \uv$$ is an orthonormal basis for $$3$$-space.

4. We want to transform the second basis to the first. Let's assume everything is written as column vectors, and let $$K = \pmatrix{\vv& \nv_1 & \uv}$$ be the matrix with $$\vv, \nv_1,$$ and $$\uv$$ as its columns, and let $$L = \pmatrix{\vv& \nv_2 & \wv}$$ be similarly constructed.

5. Let $$R = L K^t$$. Then $$R$$ is a rotation taking the first plane to the second.

Let's work through those general steps for your particular case, where $$\nv_1 = \pmatrix{-3/5 \\ 4/5 \\ 0}$$ and $$\nv2 = \pmatrix{0 \\ 0 \\ 1}$$ are the normal vectors for the two planes. As it happens, because your two normal vectors are already perpendicular, something very simple happens along the way, but you may find yourself wanting to solve the more general problem later, which is why I gave the more general answer above.

1. Compute $$\nv_1 \times \nv_2 = \pmatrix{4/5 \\ 3/5 \\ 0}$$. The length of this vector happens to be $$1$$, so dividing by that length gives $$\vv = \pmatrix{4/5 \\ 3/5 \\ 0}$$.

2. Compute $$\wv = \vv \times \nv_2 = \pmatrix{3/5\\-4/5 \\ 0}$$.

3. Compute $$uv = \vv \times \nv_1 = \pmatrix{0\\0\\1}$$.

4. We let $$K = \pmatrix{ 4/5 & -3/5 & 0 \\ 3/5 & 4/5 & 0\\ 0 & 0 & 1}, L = \pmatrix{ 4/5 & 0 & 3/5\\ 3/5 & 0 & -4/5\\ 0 & 1 & 0}$$

5. We compute $$M = LK^t = \pmatrix{ 4/5 & 0 & 3/5\\ 3/5 & 0 & -4/5\\ 0 & 1 & 0} \pmatrix{ 4/5 & 3/5 & 0 \\ -3/5 & 4/5 & 0\\ 0 & 0 & 1} = \pmatrix{ 16/25 & 12/25 & 3/5 \\ 12/25 & 9/25 & -4/5\\ -3/5 & 4/5 & 0}$$

... and that should be your matrix.

• Thanks for your answer. I actually understood how to construct one now. But I might have looked for the wrong solution regarding my initial problem (which I was too shy to ask here). Maybe for educational reasons I'll ask another questions where projection will be the right answer as my research didn't give me that on. – Patrick B. Nov 25 '18 at 17:05

My goal is to find the coordinates of any point $$P$$ of $$e$$ on $$f$$.

Looks like what you need is actually a projection of any point $${\bf . x}\in e$$ onto $$f$$. Call $$\hat{n}_f$$ a normal vector of the plane $$f$$, in your case

$$\hat{n}_f = \pmatrix{0 \\ 0 \\ 1}$$

Now, calculate

$${\bf x}_f = {\bf x} - ({\bf x}\cdot\hat{n}_f)\hat{n}_f$$

• Hmm, it seems to work actually like this. Did I go in the wrong direction in the first place? I'll try this with my real world problem to whether I actually understood my problem in the first place. Thanks. – Patrick B. Nov 25 '18 at 17:02
• No, I definitely don't want a projection. I need a rotation. The distance of the point from (0,0,0) needs to be the same on both planes. – Patrick B. Dec 2 '18 at 9:10