0
$\begingroup$

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.

$\endgroup$
2
$\begingroup$

The core calculation seems to be

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

  radius = normalize_v3(vec);

  tratio = ratio * td->factor;

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

  add_v3_v3v3(td->loc, tc->center_local, vec);

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.

$\endgroup$
  • $\begingroup$ Ok, I will try this asap and mark as answer if it works; thanks a lot for the help in deciphering the code! $\endgroup$ – Sheljohn Jun 19 at 9:38
  • $\begingroup$ 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. $\endgroup$ – Sheljohn Jun 19 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.