# How do I find the generalized coordinates in a certain system?

I'm learning about constraints and I know the following: If there are $N$ particles in 3 dimensional space, I have $3N$ degrees of freedom. If I have $n_b$ holonomic constraints and I switch over to generalized coordinates, I'm left with $n_q = 3N - n_b$ degrees of freedom.

Now let me give an example:

1 particle moves over the surface of a sphere. This initially gives me 3 degrees of freedom ($x$, $y$ and $z$). Now using the 1 holonomic constraint I have (the surface of the sphere, $x^2+y^2+z^2=R$) I should be left with 2 degrees of freedom.

This is where I get lost and don't know what else to do, my book says these 2 new degrees of freedom are angles, namely $\theta$ and $\phi$ and that that would give me the following:

$$x=R\sin{\theta}\cos{\phi}$$
$$y=R\sin{\theta}\sin{\phi}$$ $$z=R\cos{\theta}$$

How do I know that these 2 new degrees of freedom (my generalized coordinates) are angles and how do I find the equations to express $x$, $y$ and $z$ in these new coordinates?

Any 'sufficiently nice' set (in this case, pair) of variables that are compatible with the constraints will do: longitude and latitude are just one possible choice among many others.

Generally, we cannot find a sufficiently nice set of parameters to cover the whole constraint surface. Instead, we use multiple compatible coordinate neighbourhoods (where compatible means that transition maps on overlapping neighbourhoods must be diffeomorphisms), yielding the structure of a differentiable manifold.

For your particular example, in addition to the given parametrization $$(\phi,\theta)\mapsto(R\sin\theta\cos\phi,R\sin\theta\sin\phi,R\cos\theta)$$ we could also use $$(z,\phi)\mapsto(\sqrt{R^2-z^2}\cos\phi,\sqrt{R^2-z^2}\sin\phi,z)$$ inspired by cylindrical coordinates, and stereographic projection would work equally well.

In fact, the upper hemisphere can be covered with just $$(x,y)\mapsto(x,y,\sqrt{R^2-x^2-y^2})$$ ie one way to get a parametrization is by 'inverting' the constraints after a choice of independent variables.