You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
clusterizer: Adjust bounding sphere math wrt radii
Both when establishing the initial sphere, and when correcting the
sphere for outlier points, we need to move the center point along the
edge between the two points. The initial sphere center lies on the
midpoint of the edge only if the two radii are the same; otherwise, we
need to move it such that the distance between the point and the
boundary of both spheres is the same.
The computation is easy to derive, for example for initial sphere, the
distance from first boundary to the resulting point for unknown k is:
r1 + d * k == d * (1 - k) + r2
2d * k == d + r2 - r1
k = (d + r2 - r1) / 2d
The derivation for the case where we need to expand the sphere is
similar. Note that if the two points are the same or very close, k
becomes indeterminate - but it also is irrelevant as the edge reduces to
a point, as such there's no need to move anything. We guard against this
unlikely case to avoid division by zero.
0 commit comments