Last active
September 8, 2022 12:50
-
-
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)
This file contains 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_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