<p>It's easy to work out if you consider not that case but the angle at v3 (if the "cube" were continued past v3). By the time you get to v3, the angle is simply the desired bend angle. (That's not quite right, though: because you've got alpha on the decreasing side, it's 90 degrees minus the desired angle.) You have to split that angle equally among all the segments going along the bend direction, so the angle alpha is simply 90 degrees minus (the desired angle divided by the number of vertices). So for A, where the requested angle is 90 degrees, each vertex gets a third of that angle: alpha is (90 - 30) degrees.</p>

<p>For cube B, if the total bend is 35 degrees, each vertex gets just over 11 degrees, so alpha is just under 79 degrees.</p>

<p>This <strong>doesn't</strong> generalise to an arbitrary axis, though. It only works for bends like those in your diagram. For a more general (and more useful!) tool, it makes more sense to simply apply a 2D rotation (about the axis) to each vertex independently. Exactly what rotation to apply depends on some design decisions about how the bend should behave when the axis goes through the mesh, and how strong a bend you want to allow. The crucial point is that it's not the same rotation for every vertex: the rotation is proportional to the perpendicular distance from the vertex to the neutral line of the transformation. In your example, the neutral line is the bottom edge of each cube.</p>

CC BY-SA 3.0
2016-06-13T08:21:17.957Z
2016-06-13T08:21:17.957Z
Dan Hulme
<h2>α = 90° - β/4</h2>
<p>Lets call the bend angle <code>β</code>.
The math is quite easy after following observation:</p>
<p><a href="https://i.sstatic.net/Xv0WO.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Xv0WO.png" alt="enter image description here" /></a></p>
<p>We can draw a perpendicular bisector <code>middle-&gt;w</code> of the isoscles triangle <code>v1-&gt;middle-&gt;v2</code>. Then the anlge at <code>v1</code> is the desired <code>α</code>, the angle at <code>w</code> is <code>90°</code> and the angle at <code>middle</code> is just <code>β/4</code>.</p>
<p>By the <a href="https://en.wikipedia.org/wiki/Sum_of_angles_of_a_triangle" rel="nofollow noreferrer">triangle postulate</a> the sum of the interior angles of a triangle is <code>180°</code>. By applying this to our new triangle we get
<code>180° = α + 90° + β/4</code>, so we get</p>
<h2>α = 90° - β/4</h2>

CC BY-SA 3.0
2016-06-13T10:28:12.603Z
2016-06-13T10:28:12.603Z
2020-06-18T08:32:12.800Z
flawr
<p>I'm trying to write a mesh deformer that bends a Cube around an axis like this:</p>

<p><img src="https://i.sstatic.net/5pDaI.png" alt="3D Bend"></p>

<p>The bend degree in figure A is 90 and something like 35 in B. So if I know my desired bend degree how can I get alpha?</p>

<p>I know that the distance between the vertices v1 and v2 stays the same and that i basically just have to rotate the edge alpha degrees. I can't figure out where the center of the Circle has to be, so that the bend looks organic.</p>

CC BY-SA 3.0
2016-06-10T14:45:32.137Z
Looks like simple trigonometry to me, if you consider that the two triangles are mirror images of each other. The triangle (v1, v2, middle) is isosceles and you know both the length of v1-v2 and the angle defined by (v1, middle, v2), so you should be able to calculate both v1-middle and alpha.
Quinchilion
CC BY-SA 3.0
2016-06-10T15:00:36.320Z
I don't know where middle is, though. I only have the vertices of the cube and a degree by which I want it bend.
lega
CC BY-SA 3.0
2016-06-10T15:45:36.743Z
If you know where v1 and v2 are, you can calculate where 'middle' is from the requested angle. If you don't, can you clarify the problem? I see no cube in the picture.
Quinchilion
CC BY-SA 3.0
2016-06-10T15:55:16.443Z
http://prntscr.com/ber3a7 that is input and result (with a 45° angle). Those are Screenshots from Cinema4D's bending tool. As you can see the 45° is the angle of the topmost edge of the cube. The bending process strectches the sides but not the 'spine' of the object. I'm trying to emulate the tool in code with a given Mesh.
lega
<3d><mesh><model>
Implement own Bend function
lega
# Implement own Bend function

(Asked by: username_0 on 2016-06-10)

I'm trying to write a mesh deformer that bends a Cube around an axis like this:

![3D Bend](https://i.sstatic.net/5pDaI.png)

The bend degree in figure A is 90 and something like 35 in B. So if I know my desired bend degree how can I get alpha?

I know that the distance between the vertices v1 and v2 stays the same and that i basically just have to rotate the edge alpha degrees. I can't figure out where the center of the Circle has to be, so that the bend looks organic.

**Tags:** 3d, mesh, model

> **Comments:**
> **username_1**: Looks like simple trigonometry to me, if you consider that the two triangles are mirror images of each other. The triangle (v1, v2, middle) is isosceles and you know both the length of v1-v2 and the angle defined by (v1, middle, v2), so you should be able to calculate both v1-middle and alpha.  
> **username_0**: I don't know where middle is, though. I only have the vertices of the cube and a degree by which I want it bend.  
> **username_1**: If you know where v1 and v2 are, you can calculate where 'middle' is from the requested angle. If you don't, can you clarify the problem? I see no cube in the picture.  
> **username_0**: http://prntscr.com/ber3a7 that is input and result (with a 45° angle). Those are Screenshots from Cinema4D's bending tool. As you can see the 45° is the angle of the topmost edge of the cube. The bending process strectches the sides but not the 'spine' of the object. I'm trying to emulate the tool in code with a given Mesh.  

---

## 2 answers

### Answer by username_2 on 2016-06-13. Score: 2

It's easy to work out if you consider not that case but the angle at v3 (if the "cube" were continued past v3). By the time you get to v3, the angle is simply the desired bend angle. (That's not quite right, though: because you've got alpha on the decreasing side, it's 90 degrees minus the desired angle.) You have to split that angle equally among all the segments going along the bend direction, so the angle alpha is simply 90 degrees minus (the desired angle divided by the number of vertices). So for A, where the requested angle is 90 degrees, each vertex gets a third of that angle: alpha is (90 - 30) degrees.

For cube B, if the total bend is 35 degrees, each vertex gets just over 11 degrees, so alpha is just under 79 degrees.

This **doesn't** generalise to an arbitrary axis, though. It only works for bends like those in your diagram. For a more general (and more useful!) tool, it makes more sense to simply apply a 2D rotation (about the axis) to each vertex independently. Exactly what rotation to apply depends on some design decisions about how the bend should behave when the axis goes through the mesh, and how strong a bend you want to allow. The crucial point is that it's not the same rotation for every vertex: the rotation is proportional to the perpendicular distance from the vertex to the neutral line of the transformation. In your example, the neutral line is the bottom edge of each cube.


---

### Answer by username_3 on 2016-06-13. Score: 0

## α = 90° - β/4

Lets call the bend angle `β`.
The math is quite easy after following observation:

[![enter image description here](https://i.sstatic.net/Xv0WO.png)](https://i.sstatic.net/Xv0WO.png)

We can draw a perpendicular bisector `middle->w` of the isoscles triangle `v1->middle->v2`. Then the anlge at `v1` is the desired `α`, the angle at `w` is `90°` and the angle at `middle` is just `β/4`.

By the [triangle postulate](https://en.wikipedia.org/wiki/Sum_of_angles_of_a_triangle) the sum of the interior angles of a triangle is `180°`. By applying this to our new triangle we get
`180° = α + 90° + β/4`, so we get

## α = 90° - β/4


---

