Draw tubes with color gradient defined by the curvature

Dear all,

I am rather new in Blender and have unfortunately only a moderate knowledge of python. I would like, for a scientific sketch, to draw some thin flexible tubes, whose colour varies along the tube according their curvature.

What I did till know:

  • drawing the tubes, i.e., a cylinder following a bezier line.
  • I managed to export the bezier control points parameters (handles and coordinates), or, alternatively, to interpolate between the control point and get a file with a series of x,y,z coordinates.
  • From a triplet of coordinates I can define the curvature, as the reciprocal of the radius of the circle passing through three adjacent points. I can transform this information into a number between 0 and 1, or in a code (rgb, hex) defining the colour of the given point.

Now I got stuck trying to transform this file of x,y,z, colour into a coloured, flexible tube in blender. Do you have any suggestion?

I guess there are also easier procedures, which do not need this long workaround.

Thanks in advance for any help,
Leo