Message Boards Message Boards


Modeling deviations from a spherical cap?

Posted 1 month ago
2 Replies
1 Total Likes

I have this point cloud that represents {x,y,z} coordinates of the surface of a convex lens. I would like to compute the deviations of each point from a spherical cap that would be the best fit to the data. I tried using FindFit, but the results don't make any sense and I get widely different results depending on my initial guesses. Any suggestions?

FindFit[{#[[1]], #[[2]], #[[3]], 1} & /@ centerA, ((x - a)^2 + (y - b)^2 + (z - c)^2)/r^2, {{a, 0.005}, {b, 0.005}, {c, 1}, {r, 1}}, {x, y, z}]
2 Replies

You could do it with Minimize:

data = RandomReal[{0, 1}, {10, 3}];
dist[{x_, y_, z_}] = RegionDistance[Sphere[{a, b, c}, r], {x, y, z}];
Minimize[{Total@Map[dist, data], r > 0}, {a, b, c, r}]

That works really nicely. Thanks. I didn't know the RegionDistance function; very useful!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract