Message Boards Message Boards

0
|
3709 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Modeling deviations from a spherical cap?

Posted 2 years ago

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}]
Attachments:
POSTED BY: Claudio Argento
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}]
POSTED BY: Gianluca Gorni

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

POSTED BY: Claudio Argento
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract