# Inflate 3D mesh into sphere

I am after a simple (not necessarily efficient) algorithm to "continuously" transform a closed surface mesh into a sphere.

It seems that Blender is able to do this quite well: https://docs.blender.org/manual/en/latest/modeling/meshes/editing/transform/to_sphere.html

However I cannot find a reference, or technical description of the algorithm they use. I tried looking at the code but did not managed to figure out what it does unfortunately.

The core calculation seems to be

  sub_v3_v3v3(vec, td->iloc, tc->center_local);

tratio = ratio * td->factor;

mul_v3_fl(vec, radius * (1.0f - tratio) + t->val * tratio);



Which in C-ish psuedo code looks like

vec = pos - center; //find vector from center to point
radius = length(vec); // get the length of the vector
vec = vec / radius;  //normalize the vector

tratio = ratio * individual_sensitivity; // adjust sensitivity per vertex

vec = lerp(vec * radius, vec * t->val, tratio); //linearly interpolate between the original and where the point would be on the sphere

pos = center + vec; // store result


So the code projects the point to the sphere and linearly interpolates the point between the original location and the sphere location.

• Ok, I will try this asap and mark as answer if it works; thanks a lot for the help in deciphering the code! Jun 19, 2019 at 9:38
• This only seems to work if the original surface is convex; if it is not, this creates "folds" in the resulting sphere, which effectively corrupts the neighbourhood information from the original mesh. Jun 19, 2019 at 10:45