Possible Duplicate:
Efficiently sampling points uniformly from the surface of an n-sphere
I'm trying to generate random points of a (n-2)-sphere on a n-hyperplane so basically the intersection of a (n-1)-sphere and a n-hyperplane.
The hyperplane here is the plane associated with a (n-1)-simplex of equation: $x_1 + x_2 + ... + x_n = 1$
I know the radius $R$ of the n-sphere and I know the center $a$ which is in the simplex. $a = (a_1, a_2, ..., a_n)$ and $a_1+a_2+...+a_3=1$
So the points I want to generate are solution of :
$x_1 + x_2 + ... + x_n = 1$ and $(x_1-a_1)^2 + (x_2-a_2)^2 + ... + (x_n-a_n)^2 = R^2$
I absolutely need to generate points uniformly and in Cartesian coordinates.
I have been looking into it for a few days now and cannot seem to find a good way to do it.
For the moment I did it on $\mathbb{R}^3$ which is equivalent to generate points of a circle on a plane. To do so, I projected the space on the 2-simplex (3D->2D) and I generated points of a circle using :
$(u,v) = \frac{R}{\sqrt{X_1^2 + X_2^2}}(X_1,X_2)$ where $X_1, X_2$ are independent gaussians.
(this algorithm allows you to generate points on a n-sphere too)
Finally, I used an "inverse-projection" of the simplex to the space (after some calculus...) :
$z = \sqrt{2/3} \cdot v $
$y = \frac{u}{\sqrt{2}} - 1/2 \cdot z$
$x=1-y-z$
Here is a graph to give you an exemple of what I just presented in 3 dimensions. The standard 2-simplex is the area represented in cyan.
http://www.freeimagehosting.net/t/aksf6.jpg (sorry cannot post image tags...)
Of course, those formulas are easily derived in 3 dimensions but not as easily in $\mathbb{R}^n$.
I feel like I am looking at the problem the wrong way so any idea is welcome.
Thanks.