I have a mathematica problem in theoretical physics:

There is a rotation axis $\vec{n}$ with $|\vec{n}|=1$. Each other vector $\vec{v}$ can be seperated in relation to $\vec{n}$ in a parallel part and a part vertically to $\vec{n}$:



$$\vec{v}_{||}=(\vec{v}\cdot\vec{n}) \, \vec{n}$$


A rotation around rotation axis $\vec{n}$ with a rotation angle $\alpha$ is described by :

$$D_{\alpha\vec{n}}\vec{v}=\vec{v}_{||}+\cos(\alpha) \, \vec{v}_\perp+\sin(\alpha) \, (\vec{n}\times\vec{v}) \tag{1}$$

a) How could a procedure look like, that calculates the parallel $\vec{v}_{||}$ and a vertical part $\vec{v}_\perp$for vectors $\vec{n}$ and $\vec{v}$ ?

b) How could a procedure look like that turns a vector $\vec{v}$ usig equation (1) for a given rotation axis $\vec{n}$ and rotation angle $\alpha$?

  • 1
    $\begingroup$ Give an example n, v, and alpha or you won't get much much help. Also look up dot and cross products in the help pages and give it a try. $\endgroup$ – Bill Watts Jan 19 '19 at 18:53

Generating random normal, vector, and angle:

n = RandomPoint[Sphere[]];
v = RandomReal[{-1, 1}, 3];
α = RandomReal[{-Pi, Pi}];

Computing the rotated vector:

vpar = n n.v;
vperp = v - vpar;

vrot = vpar + Cos[α] vperp + Sin[α] Cross[n, v];

Let's check correctness by comparing vs. RotationMatrix:

RotationMatrix[α, n].v == vrot


  • $\begingroup$ Be blessed Henrik! Thank you $\endgroup$ – Tom Jan 19 '19 at 18:42
  • $\begingroup$ You're welcome. $\endgroup$ – Henrik Schumacher Jan 19 '19 at 18:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.