# Help using edges to rotate mesh in geometry nodes

After all the rotation node updates, I STILL don’t know how to use rotation nodes the way I want in Blender. I have some idea how they work. But not enough knowledge to figure out how to do what I want to do with rotation nodes.

Basically, the idea is this: I have 2 objects, right? One object is a mesh. For the sake of example, just imagine a cylinder. The second object is just an edge. That’s it. Just an edge. I put the edge INSIDE the cylinder. Like how you might do, if you wanted to parent the mesh to a bone. You would put the bone inside the mesh. So the edge object goes into the mesh object.

Then, in geometry nodes, I make the cylinder sample the position of the edge. And make it so that the cylinder moves in relation to the edge. Wherever the edge moves, the cylinder moves with it. Again, like you would do if the mesh is parented to a bone.

The problem is that while I can make the cylinder match the position of the edge. I can’t make the cylinder match the rotation of the edge. I figure it’s possible. But how??? My best guess is to use the “vector rotate” node. With that, I can manually input the rotation. But I can’t make it automatically match the rotation of the edge.

I feel like I’m missing some core knowledge of rotation that’s preventing me from utilizing the rotation nodes. But I don’t know what that core knowledge is, or how to attain it. I just learned what radians were not too long ago, and I know that Blender uses them. I would appreciate any further insight to rotations. But if you don’t feel like explaining, then I’ll settle for just getting the working nodes. Please, and thank you.

Sounds simple, make sure the edges origin is at the same spot as the origin of the cylinder and use the transform geometry node.

Now when you move or rotate the edge the cylinder will move and rotate.

If you do this;

It uses all the transforms (including scale), which would be the same as plugging the scale to scale in my first example.

1 Like

Ah. Ok. I oversimplified the matter. This is my fault. You have the right solution. Just not to the right problem. I should have explained it better. I shouldn’t have said a single edge. But rather 2 edges, or 3 or 4 or more. Multiple edges in the same mesh. How would you make the mesh follow the rotation of an edge, when you have multiple edges?

1 Like

Here is a way to directly sample an edge by index:

This could probably be extended to work on a field of edges, rather than a single edge.

2 Likes

I think SterlingRoth has it, turning the vertex positions of the edge into a vector (with the vector math subtract ), he is using the sample index to choose the edge.

Here the 3 edges are one object called edges, the GN is on the cylinder, this will place the cylinder on the edge position with its rotation (not the edge in the cylinder). the integer chooses which edge to use.

1 Like

ok, so subtract the edge vertices, plug that into align euler to vector, and then that magics the rotation.

Well, there are some problems with that. I do want to make this to work on a field of edges. Different parts of the mesh can be assigned to different edges by using the sample nearest node on a “resting” mesh of edges. For simplicity sake, I only have two edges. So half the cylinder samples one edge, and the other half samples the other edge.

The problem is that the mesh assigned to one edge aligns correctly, while the mesh assigned to the other edge aligns backwards. I can change the mesh’s direction based on which edge vertex gets subtracted from the other. Effectively making it so that incorrectly facing mesh faces correctly. And the correctly facing mash faces incorrectly. I can’t seem to make them both face the correct direction. I can force one side to avoid moving by selecting what moves in the set position node. But that’s not a real solution. Because I do want every part of the mesh to be capable of rotating along with their respective edge.

There’s another problem too. Actively moving the edges seems to cause the mesh to “roll” slightly as it’s moving. Here’s the blend file if you want to see what I’m doing exactly. It’s 4.2. But the only difference is the align euler to vector node having been replaced by the"align rotation to vector node". Same thing pretty much.
Deformation test.blend (1.1 MB)

I’m a step closer to the solution. Thanks to CGMatter’s video about rotation: https://www.youtube.com/watch?v=lbCHEHkyRts

I copied his rotation math, and it just worked. I don’t understand it at all. I only recently learned what cosine is. The concept is slippery. But in any case, it works.

The problem remains: how to make this work in the manner of a field. I was only able to make this work by manually sampling the pivot point. But I need it to automatically sample all the pivot points for as many edges are in the mesh. But I don’t know how. I recall there being a way to sample specific vertices of edges. Don’t remember how exactly. Something to do with booleans and a switch node…

I worked out the index problem. I had to use vertex groups in order to manually select which points will be pivot points. All of the edges have to be disconnected, in order to ensure there’s only one pivot point per edge.

Then, taking the attribute of the vertex group into nodes, I can use it like a boolean. Since booleans are 0 for false and 1 for true. The vertices weighted as 1 are true. Then I do the switch trick to only pass the true vertices through, and that gives the index of the pivot points.

There was another problem where despite the two edge meshes being identical, they still somehow ended up listing points in the index in different orders. So I used the sort index node on both, in order to get them to sort their points in the same order. Surprisingly, the sort index node affects edit mode too! You try to move one point, only to find another point is moving.

Deformation test.blend (1.5 MB)