6
$\begingroup$

enter image description here

I’ve been taught that the Axis input is the value for input vector n^ of the Rodrigues’ rotation formula:

v’ = (1-cos(θ))[(v·n^)n^]+cos(θ)v+sin(θ)n^×v

But I don’t understand what ‘’Center’’ input do. And its effect on the Rotation. I’ve done some tests in Blender. With Center = (0,0,0) and n^ = (0,0,1) the result looks like the following diagram:

Description: All vectors including v rotate around vector n^ = <0,0,1> (AKA Axis input) with its ‘’Center?’’ = <0,0,0> (AKA center input) for a θ angle

With Center = (1,0,0) and n^ = (0,0,1), the result looks like the following diagram:

enter image description here

Description: All vectors except for v rotate around vector n^ = <0,0,1> (AKA Axis input) with its ‘’Center?’’ at <1,0,0> (AKA center input) for a θ angle.

So my guess is: Axis input is to control direction, Center input is to control position? I’ve done researching and found out about the ‘’Rotation around a pivot point’’ formula:

p.x’ = [(p.x-o.x)*cos(θ)-(p.y-o.y)*sin(θ)]+o.x

p.y’ = [(p.x-o.x)*sin(θ)+(p.y-o.y)*cos(θ)]+o.y

This formula basically applies for cases where the ‘’point’’ of rotation is any where except for the Origin = (0,0,0)

enter image description here

But is this actually the case? Was this formula used for the instance where Center input = (1,0,0) ?

So my question is: what’s actually the math behind the Vector Rotate node? Assume I’m gonna use just Rodrigues’ Formula instead of Matrix 3D Rotation, what are the formulas, the steps and computations gonna be? Is ''Axis'' input actually used to define the direction for all vectors to rotate around and ''Center'' input to define the point for all vectors to rotate around? Illustration on how the process go would be greatly appreciated.

All of what I’ve said above are just speculations on how the node work but I need actual math and the proof of it.

Please explain like I’m five. Explanation along with mathematical proof would be amazing. Thank you!

In case, if anyone wants to illustrate a diagram for me, you can use mathcha.io , it’s a very cool ‘’write and share’’ mathematic site.

$\endgroup$
6
3
$\begingroup$

3D transformations, like rotation, occur about the origin: 0,0,0. (The origin of what space? Whatever space you're measuring your coordinates in.)

However, the math to do 3D transformations about any other point is straightforward: you translate all points by what it takes to translate your center to 0,0,0, then you do your transformation, then you do the inverse translation for all your points.

One way to think about this is that we're not measuring in the same space as our coordinates; we're transforming the space into a new coordinate system where we can rotate about the origin, then we're transforming those coordinates back into our original coordinate system.

So given a point P [Px,Py,Pz] and a center C [Cx,Cy,Cz] and a rotation function f(x,y,z), then you:

  1. P = P-C
  2. P = f(P)
  3. P = P+C

Or, as a function instead of an algorithm:

P = C + f(P-C)

By the way, this is true of scaling as well as rotation.

As for what exact code is used-- as you can see, there are a number of ways we can word the exact same operation. We could also be doing matrix multiplications to transform the spaces. But when all of these different techniques give the exact same output for any given input, they are isomorphic-- they are the same function, just expressed with different symbols.

$\endgroup$
3
  • 1
    $\begingroup$ Thank you for explaining how rotation around a pivot point work. But can you please explain how the formulas work if there is any? 1. What are the formulas for the ''Center'' input? 2. How do they work? 3. How are they gonna work correspondingly with the Rodrigues' Rotation formulas which is also the formula for the ''Axis'' input? 4. What are the mathematical proof? - These above are also the questions that were written in my post. Because you know, I need the formulas do the calculations - Thank you. $\endgroup$ Oct 20 at 5:14
  • $\begingroup$ Hi Nathan, I've successfully written the formula thanks to the hints from your answer. Really appreciate your help. I'm sorry if I was being a d!ck earlier. $\endgroup$ Oct 22 at 1:18
  • 1
    $\begingroup$ @IanAmbrose Not at all, and I'm happy to be of some help. I know people get their information best in various ways, and maybe I can help present it in a useful way, and maybe I can't-- it doesn't just depend on me, but on the person I'm speaking with. So if it's not the best way for someone in particular, that's fine. $\endgroup$
    – Nathan
    Oct 22 at 2:15
0
$\begingroup$

The source code for the Vector Rotate implementation is in this file in the official github mirror of the source code.

The key bit with respect to center is at line 48:

result = transform_direction(&rotationTransform, vector - center) + center;

It tells us that the center is being used to offset the vector before it is being rotated. Probably something that should be in the manual description of the node.

$\endgroup$

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.