3
$\begingroup$

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

$\endgroup$

2 Answers 2

4
$\begingroup$

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:

Example

$\endgroup$
2
  • $\begingroup$ It doesn't look like it's 'rolling' around the axis though... $\endgroup$
    – Bert VdB
    Commented Dec 29, 2017 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
    Commented Dec 29, 2017 at 19:19
1
$\begingroup$

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)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .