How do you rotate an object around a given unit vector and angle? I thought I could use this matrix, but I'm unable to create a custom 3x3 matrix inside animation nodes.

$$R= \begin{bmatrix} \cos\theta+u_x^2(1-\cos\theta) & u_xu_y(1-\cos\theta)-u_z\sin\theta & u_xu_z(1-\cos\theta)+u_y\sin\theta\\ u_yu_x(1-\cos\theta)+u_z\sin\theta & \cos\theta+u_y^2(1-\cos\theta) & u_yu_z(1-\cos\theta)-u_x\sin\theta\\ u_zu_x(1-\cos\theta)-u_y\sin\theta & u_zu_y(1-\cos\theta)+u_x\sin\theta & \cos\theta+u_z^2(1-\cos\theta) \end{bmatrix} $$


You can use the Convert Rotation Types node to construct a rotation matrix from Axis Angle model and then use it to rotate the object:


  • $\begingroup$ It doesn't look like it's 'rolling' around the axis though... $\endgroup$ – Bert VdB Dec 29 '17 at 19:14
  • $\begingroup$ @BertVdB May be you should choose one of the fundamental axis to see it clearer. Let me know if you still don't think it is the result you want. $\endgroup$ – Omar Emara Dec 29 '17 at 19:19

I found a way to create a matrix like this using the script-subprogram method in animation nodes:

Node setup: Node setup

And the following script:

import bpy
from mathutils import Matrix

Rotation = Matrix.Rotation(angle, 4, axis)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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