# How can I fold a mesh using geo nodes?

I'm new to geo nodes and I have a simple project. I want to fold this shape, as if it was made of paper, origami style.

So i figured it means I want 2 things

• that all the edges keep their original length
• and that while the central vertex goes down the z axis, all the other vertices follow along without leaving the xy plan.

I guess it involves some nodes like "map range" with clamp, maybe index vertices.. I watched a lot of tutorials but I'm still a bit lost and would love some hints on how to achieve this.

• How do you make the mesh transparent around the edges? There was a question here some time ago that asked for that ðŸ¤” Commented Jan 5, 2022 at 23:15
• why do you want to do that with geometry nodes? if you are open to other solutions, i would propose to use e.g. an armature.... Commented Jan 6, 2022 at 4:29
• @ Markus, I'll take a pic of the node tree when I'm back at home, but in short I use a split edges node. And @Chris, the idea is then to tessalate the origami pattern using two array modifiers and have precise control over the folding. But while I'm waiting for an answer I'll explore the armature solution and try to create a long string of bones Commented Jan 6, 2022 at 9:28
• Ah, I see, I thought maybe it's some display setting I don't know about. Commented Jan 6, 2022 at 11:22

The way I understood your problem, for known $$a$$ and $$b$$, you want to find such $$a'$$, that $$c' = a$$. By $$a'$$ and $$c'$$ I mean changed lengths of the triangle sides when the vertex connecting $$a$$ and $$c$$ moves.

$$a'^2 + b^2 = c'^2$$â€ƒâ€ƒ|â€ƒâ€ƒ$$c' = a$$

$$a'^2 + b^2 = a^2$$â€ƒâ€ƒ|â€ƒâ€ƒ$$-b^2$$

$$a'^2 = a^2 - b^2$$â€ƒâ€ƒ|â€ƒâ€ƒ$$\sqrt {}$$

$$a' = \sqrt {a^2 - b^2}$$

Once you have that, you need to move along normalized vector $$\overrightarrow{a}$$ by the difference between $$a$$ and $$a'$$. So you need to apply an offset $$n(\overrightarrow{a}) \times (a - a')$$.

So with this setup:

We get:

For it to work, you need to set the dragged vertex'es index to 0 (select the vertex, Mesh > Sort Elements > Selected).

Edge lengths will change for points that aren't directly connected to the directly dragged vertex:

I don't think you can find the shortest path in geometry nodes, but what you could do is manually assign some information on the connections to the geometry, e.g. you could add a vertex group, assign it to all vertices with value 0.0, and then assign e.g. a value 0.51 to vertex #8:

So that in the nodes you can multiply these values by 10 and have it truncate (keep in mind 0.7 is saved as 0.699999988079071044921875 in float, that's why I add a threshold in the form of 0.01 to the number, so I can just truncate the number. But rounding would work instead...) so the fraction is removed during conversion to integer, in order to obtain the coordinate of the connected vertex rather than always just one vertex:

However, in the first node setup I'm just using the info on how the dragged vertex will be moved, in order to calculate how to move neighboring vertices and only then move the dragged vertex. I could move them all at once with only one Set Position node, or I could also have two s.p. nodes, moving the dragged vertex first, and then using the evaluated position for other vertices. But this means for each level of depth, you need a separate Set Position node, at least to my (limited) understanding...

The laziest idea I have is that you just select the dragged vertex, sort it, select more, sort, and so on to quickly sort everything inside out:

(select the directly dragged vertex, Mesh > Sort Elements > Selected, or use F3 as on GIF, CtrlNumpad + to select more and repeat until everything is sorted from inside out).

Then as described above, manually assign info on indices to nearest dragging vertices, for complex geometry this could be done with a Python script + "shortest path" operator (or some bmesh code by batFinger surely flying around).

Then you would create a node setup that isn't hardcoded to look for index 0 but rather looks for index as in the vertex group, and finally (the laziest part), just take it all, pack into a custom group, and duplicate a few times (as many times as the number of depth levels you want to support), so after one level is evaluated, the next have to update as well in order to stay in correct distance...

• thank you so much for your time Markus. This is even more than what i asked for - we are unpacking your answer with a friend, we'll post a follow up next week with our result Commented Jan 7, 2022 at 0:04
• @Jonquille where's the follow up? :) Commented Jan 17, 2022 at 18:32