# $n$-dimensional rotation matrix

I want to find $n$ dimensional rotation matrix which corresponds rotation of an angle $\theta$ around the $(n−2)$-dimensional subspace.

There is the n-dimensional rotation matrix formula. (see equation $15$)

$$I+(n_2n_1^T-n_1n_2^T)\sin(a)+(n_1n_1^T+n_2n_2^T)(\cos(a)-1)$$

where $n_1$ and $n_2$ are $n$-dimensional orthogonal unit vectors.

Can anybody explain how can I use this formula, for $n=6$?

• Is $a$ supposed to be the same as $\theta$ here? Commented Apr 25 at 15:12

Here's an example application using Python / Numpy:

import numpy as np

# input vectors
v1 = np.array([1,1,1,1,1,1])
v2 = np.array([2,3,4,5,6,7])

# Gram-Schmidt orthogonalization
n1 = v1 / np.linalg.norm(v1)
v2 = v2 - np.dot(n1,v2) * n1
n2 = v2 / np.linalg.norm(v2)

# rotation by pi/2
a = np.pi/2

I = np.identity(6)

R = I + (np.outer(n2,n1) - np.outer(n1,n2)) * np.sin(a) + ( np.outer(n1,n1) + np.outer(n2,n2)) * (np.cos(a)-1)

# check result
print(np.matmul(R,n1))
print(n2)


See the result here.

Depends upon what you have at your disposal for calculating?

If you have a scientific programming language, like matlab, you construct an $n\times n$ dimensional matrix from the above formula. For example, I is just the identity, $n_2 n_1^T$ is an $n\times n$ dimensional matrix obtained by taking the product of a column vector with a row vector, etc... The resulting matrix performs an orthogonal rotation by angle $a$ in the plane spanned by $(n_1,n_2)$ and with orientation given by that couple.

With the notation $$R(\theta)=\left[\begin{array}{cc}\cos \theta&-\sin\theta\\\sin \theta&\cos \theta\end{array}\right]$$ the rotation that you consider has the following matrix representation in an orthonormal basis $$( \vec{n_1},\vec{n_2},\ldots,\vec{n_n}),$$ by blocks: $$\left[\begin{array}{cc}R(a)&0\\0&I_{n-2}\end{array}\right].$$ It is artificial to represent this rotation in the canonical basis of $$R^n$$, a natural basis should start from your $$\vec{n_1},\vec{n_2}.$$