Skip to content

Instantly share code, notes, and snippets.

@marmakoide
Last active September 8, 2022 12:50
Show Gist options
  • Save marmakoide/ca7042a769b5447380beea4a2abf3bc8 to your computer and use it in GitHub Desktop.
Save marmakoide/ca7042a769b5447380beea4a2abf3bc8 to your computer and use it in GitHub Desktop.
Computes the N-dimension circumcenter of N + 1 points (the S array) and their N + 1 radiis (the R array)
import numpy
def get_power_circumcenter(S, R):
R_sqr = R ** 2
Sp = S[1:] - S[0]
Sp_norm_sqr = numpy.sum(Sp ** 2, axis = 1)
U = ((Sp_norm_sqr + R_sqr[0] - R_sqr[1:]) / (2 * Sp_norm_sqr))[:, None] * Sp + S[0]
return numpy.linalg.solve(Sp, numpy.sum(U * Sp, axis = 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment