Last active
January 14, 2019 09:52
-
-
Save marmakoide/fe662ec88b05f08db5a99db059fa1bc6 to your computer and use it in GitHub Desktop.
Computes the N-dimension circumsphere of M points, returning its center and its radius, assuming M <= N + 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
def get_circumsphere(S): | |
U = S[1:] - S[0] | |
B = numpy.sqrt(numpy.sum(U ** 2, axis = 1)) | |
U /= B[:,None] | |
C = numpy.dot(numpy.linalg.solve(numpy.inner(U, U), .5 * B), U) | |
return C + S[0], numpy.sqrt(numpy.sum(C ** 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment