8

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.

Orange Cat
  • 592
  • 3
  • 14
  • 1
    Related https://blender.stackexchange.com/questions/194796/matrix-math-to-translate-rotate-scale-with-respect-to-a-pivot-point-in-object – batFINGER Oct 20 '21 at 02:36
  • @batFINGER actually no, the linked question isn't related in the kind of math with this question. They didn't ask and discuss about formulas, derivation and steps of the formulas related to 3D rotation. This question however did. – Orange Cat Oct 20 '21 at 02:47
  • I'm going to assume Blender is going to use a matrix to move mesh vertices, so at the end of the day we need a matrix. – Ron Jensen Oct 20 '21 at 02:52
  • @RonJensen Most of 3D softwares use matrices to perform almost every tasks regarding 3D stuff. The thing is formulas can be translated into matrix form and vice versa. And I need the mathematical formulas and derivations of the formulas and the proof behind it, just like what the question is about. But thank you for commenting. – Orange Cat Oct 20 '21 at 03:00
  • 1
    Related https://stackoverflow.com/questions/14607640/rotating-a-vector-in-3d-space and https://blender.stackexchange.com/questions/240142/what-does-axis-input-of-vector-rotate-node-do – Gorgious Oct 20 '21 at 06:26
  • 2
    Nathan is correct. See sh_node_vector_rotate_around_axis, which calls axis_angle_to_mat3 for the rotation matrix. – scurest Oct 20 '21 at 08:21

1 Answers1

4

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.

Nathan
  • 24,535
  • 1
  • 22
  • 68
  • 1
    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.

    – Orange Cat Oct 20 '21 at 05:14
  • 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. – Orange Cat Oct 22 '21 at 01:18
  • 1
    @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. – Nathan Oct 22 '21 at 02:15