Drawing objects with an interpolated function

I need to draw some complex/irregular objects that could be simply drawn if I could use a function to draw a line and spin it around an axis (say X’s).

As an example, take the cylinder. Your f(x) = a, while a constant, draws the line, then spining it around X axis it would draw a cylinder.

Is it possible?