Last active
January 6, 2017 06:57
-
-
Save anael-seghezzi/c946c41dbd839a193553b245315277b2 to your computer and use it in GitHub Desktop.
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
// hyper-sphere coordinates | |
void n_sphere(float *out, float *in, int n) | |
{ | |
double x; int i; | |
x = in[0] * in[0] + in[1] * in[1]; | |
out[1] = in[0] < 0 ? M_PI*2 - acos(in[1] / sqrt(x)) : acos(in[1] / sqrt(x)); | |
for (i = 2; i < n; i++) { | |
x += in[i] * in[i]; | |
out[i] = acos(in[i] / sqrt(x)); | |
} | |
out[0] = sqrt(x); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment