[Math] $ n$-dimensional rotation matrix

linear algebramatrices

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$?

Best Answer

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.