dirkdeftly
14th July 2002 22:08 UTC
n-hyperspherical coordinates
What is the forumla for n-hyperspherical coordinates?
I've been trying to create higher dimensional spheres...but I can't quite get the coordinates right:
x=sin(i*tpi*r*d);
y=sin(i*tpi*r*(d-1))*cos(i*tpi*r*d);
z=sin(i*tpi*r*(d-2))*cos(i*tpi*r*(d-1))*(cos(i*tpi*r*(d-2));
...
Any ideas?
dirkdeftly
15th July 2002 02:20 UTC
Whoops, forgot to mention that r is the number of nested spheres (every ring in the sphere, every sphere in the hypersphere, etc)
And while we're at it, how would I find the correct shifting value on eachb axis so that a n-sphere of radius 1 would be projected inside a circle of radius 1?
Example: A 3-sphere of radius 1 has to be shifted by sqrt(2) to be projected inside a circle of radius 1
UnConeD
15th July 2002 13:09 UTC
The idea is pretty simple... start with a regular circle, and keep multiplying what you already have with a new sine, and add a new coordinate that consists only of a cosine (or vice-versa):
2D:
x=cos(a);
y=sin(a);
3D:
x=cos(a)*cos(b);
y=sin(a)*cos(b);
z= sin(b);
4D:
x=cos(a)*cos(b)*cos(c);
y=sin(a)*cos(b)*cos(c);
z= sin(b)*cos(c);
w= sin(c);
The parameters should be 0..2PI for a, and 0..PI or -PI/2..PI/2 for the others.
Note that I'm not 100% sure about this, this is off the top of my head, but the idea should be correct. If I look at your code, this seems to be what you intended to do, but you made a mistake: you used (d-2) twice in the z coordinate.
As for the projection distance, regular geometry rules (pythagoras and friends) should work, but it can be very hard to visualise the situation in 4+ dimensions. I think your best bet is to find the constant yourself through experimentation. After you've found it, try exponentiating it and see if you can reduce it to a form pow(x, 1/n) or something if you really like to be exact.
dirkdeftly
16th July 2002 21:00 UTC
thanx, that's what I thought it was...
The only problem I'm having is implementing it - every time I try it it won't work...