-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Singular matrix error for points in non-generic position #6
Comments
I found a better solution -- the code never runs into the singular matrix error if the circle containment is done right: instead of checking just for inequality, we can also check for
|
Can you provide an example of such a configuration of points ? I tried this, which is a degenerate configuration but does not trigger any issues
|
Sorry for a very long time it took me to react. I don't quite understand what the problem cases are, but below I give a few examples. Note that the error only raises ~10% of the times you run
|
I have same error I would be grateful if the revision request by OnDraganov is approved. |
I got another error case. Here is the sample code.
|
The code assumes that points are in generic position in the following sense:
If the points are d-dimensional, then every p-sphere in R^d passes through at most p+1 points
If this is not the case, for example if we have four points in 3D lying on a common circle, then the difference vectors used in
get_circumsphere
are linearly dependent, and we getLinAlgError
fromnumpy.linalg.solve
.There is a good use-case for non-generic point clouds: you can restrict the center of the minimized bounding ball to an affine space by reflecting the points through that affine space. For this reason, it would be useful if the code allowed for such point clouds.
Suggested solution:
Replace
numpy.linalg.solve
bynumpy.linalg.lstsq
.The linear equation solved is of the form$U^T U x = b$ , where we then care about $c = U x$ . Therefore, if there is more solutions, it does not matter which one we take: if $x' = x + k$ is a different solution with $k \in \mathrm{Ker}\ U$ , then $U x' = U (x + k) = U x = c$ .
To treat the potential breaking case where the equation had no solutions and an approximation was returned, we can just check
np.isclose(((a @ x - b) ** 2).sum(), 0.)
, wherea, x, b
are the matrix, the returned solution, and the right hand side.Altogether I would replace line 48 with the following:
The text was updated successfully, but these errors were encountered: