3
$\begingroup$

Rotating object faces around itself using geometry nodes

I'm trying to rotate an objects faces around itself.

See torus animation for rotation example:

ani1

When I try and do it with a "complex" object this happens.

img1

img2

img3

See attached blend file:

$\endgroup$
7
  • $\begingroup$ I think it's quite difficult to make what you want from a torus object you created. What immediately comes to mind is to use Curve Circle instead, replace the points with Cubes and then rotate them by Index. The rotation will occur around their center, resulting in the "close" result you showed in the animation. Perhaps then you can merge the vertices by distance. $\endgroup$
    – Danya K
    Commented Dec 8 at 19:20
  • $\begingroup$ Thanks, the Torus was just demonstrating the rotation as an animation. The object is what I included in the static images and the blend file.. (Note: the object isn't all cubes) $\endgroup$
    – Rick T
    Commented Dec 8 at 19:32
  • 1
    $\begingroup$ So this or this isn’t what you’re after? Do you also want to rotate the "closed center"? Or am I still not quite getting what you mean? $\endgroup$
    – Danya K
    Commented Dec 8 at 20:49
  • $\begingroup$ @DanyaK Yes, like this imgur.com/a/qd1uCsy but using the complex object in the blend file / the image i.sstatic.net/0b7dLuKC.png / blend-exchange.com/b/oONVXoOE $\endgroup$
    – Rick T
    Commented Dec 8 at 22:03
  • 1
    $\begingroup$ Is this the result you wanted? $\endgroup$
    – Danya K
    Commented Dec 8 at 22:48

2 Answers 2

4
$\begingroup$

The approach I'm going to demonstrate is the simplest I can think of, but it relies entirely on the assumption that the rotation will be around the initial "core" (central circle) of the torus, in other words, the assumption is that you're not going to significantly change the torus before performing the rotation (like moving all the points to some random position). Otherwise, the method won't give the correct result. Steps:

  1. As said, the top and bottom faces first need to be split into simple faces. I just use the Triangulate node for the whole object:

No other changes in the Create object frame. Of course, you can instead just Triangulate the top and bottom faces, or you can find a way to create the correct topology inside your torus constructor. It's up to you.

  1. Now the rotation algorithm, which looks like this:

The input parameters are the ones you used when creating the torus. The basic idea here is to rotate each vertex around the "core" of the torus. You rotate each vertex around the point (Center) that is the closest point to this vertex from the "core" of the torus, the Axis is the tangent to the "core" of the torus at the vertex. Halve is just Devide the value by 2, I just renamed it for convenience.

I can write more explanation for each part of the logic if needed, but this is just math.

Now the downside of the algorithm: as I said, if you significantly change the entire torus, the rotation will no longer happen around its "core". Other algorithms will have to find a new circle (or even "ellipse") to rotate around using iterative algorithms. This is difficult and requires internet searching, and will most likely be a rather slow algorithm.

Note: You might realize that if you simply scale the torus by some value before rotating, the algorithm I showed won't give the right result. This is obvious since the central circle will be scaled, while my algorithm doesn't take any transformations into account. If you use two assumptions: the torus core is still a circle, and it is also parallel to the XY plane, then a more complex, but in this case improved algorithm for finding such a central circle for deformed torus can be provided. But I don't provide it since I have no idea if it will actually be useful. You might also rotate the torus, which would break this method as well.

$\endgroup$
3
$\begingroup$

First of all allow me some pedantism, because it's the key to understand the problem here: you're not rotating faces around themselves in your GIF. A face rotated around self wouldn't move the face's center, and in most cases (like in a torus) would require to split the face away from the rest of the geometry (if the rest isn't supposed to get deformed, which is the case when you want to rotate all faces).

So what you're doing in the GIF is rotating vertices around a common center, this "common center" being the average position of the group, and in a torus those vertices are grouped by belonging to the same cross-section loop, same inner circle of the torus.

In a torus, you can use index logic (index modulo major segments) to calculate group ID. Even if indices are shuffled you can restore them by e.g. removing non-horizontal edges, converting to curve, capturing spline index, converting to points, on original geometry sampling the captured spline index by proximity and using it in sorting as group index, plus Gradient Texture: Radial as weight to sort points.

Problem is, it's extremely hard to create a generalized algorithm finding the right spot to rotate around. For example if you found some kind of localized center of mass, it still probably wouldn't work they way you want, because extruded parts wouldn't move around the original torus "spine". You could maybe take the inner loop of faces, discriminating by e.g. normal pointing towards center, then for each vertex find the distance to such nearest face, then discard 20% or so biggest values to ignore extrusions in the calculation, calculate a weighted average, and once you know what kind of a distance from the inner face loop is the virtual "spine", you can rotate all vertices around that spine.

I don't show this, however, because there's another problem: your topology - the n-gon top and bottom - doesn't allow for twisting this torus, as the n-gon would no longer be co-planar and you would get ugly artifacts.

$\endgroup$
3
  • $\begingroup$ Thanks.. I'm also wondering if this might be a job for using the matrix nodes with a transform point node / combine transform node (since its capable of moving individual points of a mesh) ...I'll have to research that. $\endgroup$
    – Rick T
    Commented Dec 9 at 7:39
  • 1
    $\begingroup$ @RickT "since its capable of moving individual points" - as opposed to set position node? :P matrix won't help you here, the problem currently is conceptual: free yourself from any limitations of blender and ponder: can I write a pseudocode algorithm defining unambiguously how the vertices should move? $\endgroup$ Commented Dec 9 at 8:13
  • $\begingroup$ ... The "current way" was you can rotate (or scale) about arbitrary centers by first translating your origin of rotation to 0,0,0, then rotating, then doing the inverse of your translation (just multiplying the original translation vector by -1.)...Its using the correct origin of rotation I'll have to ponder on. $\endgroup$
    – Rick T
    Commented Dec 9 at 8:25

You must log in to answer this question.

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