Hi there, I am trying to follow this tutorial, where they show how to make a bending cylinder in C and opengl (at Edit2)

Would anyone who knows C be willing to turn this into a three.js codepen? Or explain how to do it in three.js

Hi there, I am trying to follow this tutorial, where they show how to make a bending cylinder in C and opengl (at Edit2)

Would anyone who knows C be willing to turn this into a three.js codepen? Or explain how to do it in three.js

@Tintinabulator_Zea out of curiosity, is this like a college homework assignment or something? I think Iโve seen @prisoner849 answering this same question about three times in the last few weeks in StackOverflow.

@marquizzo itโs not homework, iโm not in school. Itโs for a tool iโm working on, but i am stuck with some of the math language.

@Tintinabulator_Zea Another idea from the twilight zone of my mind is: maybe an easier way is just to use `THREE.TubeBufferGeometry()`

then? With some modifications, of course

Here, `radius`

should be depending on the function (sin, cos etc.) of an angle, which is `var v = j / radialSegments * Math.PI * 2;`

(see it above in the source code)

I went the path of less resistance

Just created a tube geometry and used its source code as a base to distort it (with some modifications and simplifications)

All the magic is in these lines:

```
var radius = geometry.parameters.radius;
radius += Math.abs(Math.sin(v * 2.5)); // radial half-waves
radius += Math.sin(pointAt * Math.PI * 4); // wave along the path
normal.applyAxisAngle(geometry.tangents[ i ], pointAt * Math.PI * 2); // twisting
```