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:
- 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.
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 corecircle will be scaled, while my algorithm doesn't take any transformations into account. If you use two assumptions: the central circletorus 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.