Formulas for ball rolling in a bowl? I'm developing a program where I've a ball/sphere rolling in a bowl from the side at top, till the center at bottom, and I'm trying to get the formulas for:


*

*The rotation angle and the position of the sphere, depending on the starting angle measured in radians (0.000 - 6.283), the current seconds and the maximum seconds that the ball will keep rotating and considering its deccelerated.


All I knew about the needed physics is almost already forgotten, and I'm getting horrible headaches to get a properly working formula, so hope anyone can help me.
Thanks in advance!
 A: If I understand the problem correctly there is a bowl (like a large salad bowl) and a ball rolling inside of it under the influence of gravity. Here is how to derive the equations of motion. I parametrize the position of the ball center using the quasi-coordinates $q_1$ and $q_2$ as:
  $$ \vec{r}(q_1,q_2) = [0,0,R]-{\rm Rot}_{X}(q_{1})\cdot{\rm Rot}_{Y}(q_{2})\cdot[0,0,R]$$
where $R$ is the radius of the bowl minus the radius of the ball, equals the pitch radius of motion. My coordinate system has the bowl laying on the $x$-$y$ plane and up being the +$z$ direction. ${\rm Rot}_X()$ and ${\rm Rot}_Y()$ are the $3\times3$ rotation matrices respectively.
Differentiating I get the velocity vector of the center of gravity
  $$ \vec{v}=\begin{bmatrix}0 & \cos q_{2}\\
\cos q_{2}\cos q_{1} & -\sin q_{2}\sin q_{1}\\
\cos q_{2}\sin q_{1} & \sin q_{2}\cos q_{1}\end{bmatrix}\begin{bmatrix}R\,\dot{q}_{1}\\
R\,\dot{q}_{2}\end{bmatrix} $$
and differentiating again, I get the acceleration of the c.o.g.
  $$ \vec{a}=\begin{bmatrix}0 & \cos q_{2}\\
\cos q_{2}\cos q_{1} & -\sin q_{2}\sin q_{1}\\
\cos q_{2}\sin q_{1} & \sin q_{2}\cos q_{1}\end{bmatrix}\begin{bmatrix}R\,\ddot{q}_{1}\\
R\,\ddot{q}_{2}\end{bmatrix}+\begin{bmatrix}R\sin q_{2}\,\dot{q}_{2}^{2}\\
\mbox{-}R(\dot{q}_{1}^{2}+\dot{q}_{2}^{2})\cos q_{2}\sin q_{1}-2R\dot{q}_{1}\dot{q}_{2}\sin q_{2}\cos q_{1}\\
R(\dot{q}_{1}^{2}+\dot{q}_{2}^{2})\cos q_{2}\cos q_{1}-2R\dot{q}_{1}\dot{q}_{2}\sin q_{2}\sin q_{1}\end{bmatrix} $$
Now for the fun part. The forces acting on the ball are gravity $\vec{W}=[0,0,-m\,g]$ and the contact force 
$$ \vec{N}=F\,\begin{bmatrix}\sin q_{2}\\
\cos q_{2}\sin q_{1}\\
\cos q_{2}\cos q_{1}\end{bmatrix} $$ where $F$ is the magnitude of the force (unknown), $m$ is the mass of the ball and $g$ is acceleration of gravity.
To verify that $\vec{N}$ is a reaction force check with $\vec{N}\cdot\vec{v}=0$, thus providing zero power to the system.
The equations of motion (ignoring the rotational components and friction) are
$$ \vec{W}+\vec{N} = m\;\vec{a} $$ The solution of which yields $F$, $\ddot{q}_2$ and $\ddot{q}_2$ as
$$\ddot{q}_{1}=2\dot{q}_{1}\dot{q}_{2}\tan q_{2}-\frac{g}{R}\,\frac{\sin q_{1}}{\cos q_{2}}$$
$$\ddot{q}_{2}=\mbox{-}\dot{q}_{1}^{2}\sin q_{2}\cos q_{1}-\frac{g}{R}\,\sin q_{2}\cos q_{1}$$
$$F=m\, g\,\cos q_{2}\cos q_{1}+R\, m\,\left(\dot{q}_{1}^{2}\cos^{2}q_{2}+\dot{q}_{2}^{2}\right)$$
Whats left to be done, is put it through a numerical integrator scheme like Runge-Kutta [1] [2] and watch the variables $q_1$ and $q_2$ evolve over time. 
To add friction, add a component of force in the direction opposite of $\vec{v}$ with magnitude $\mu\,F$ where $\mu$ is the coefficient of friction (like 0.02-0.10 for rolling).
A: There are several ways you could do this. Below I will outline a couple of possible approaches, but it may be that a simpler / more elegant solution exists. Here are my 2cents nonetheless.
Firstly, it would be a lot easier if you first consider the motion of a zero-radius ball and worry about making it bigger and appearing as if it's 'rolling' later on. Here's how I think you could approach the motion of a zero-radius ball, in the bowl.
You would need to program time-evolution equations of motion for each of the three dimensions individually. You could do this in your choice of coordinate system. For the geometry of the apperatus you are trying to model, I think cylindrical coordinates $(r,\theta,z)$ would be easier than cartesian coordinates $(x,y,z)$. In which case, you would need just a circular motion equation (relating $r$ and $\theta$ with time,) with the addition of a resistive term to simulate the energy loss and therefore reduction of the 'orbital' radius. The fall in $z$ could then be determined from the (varying) $r$-value with respect to the geometry of your bowl. I.e. A smaller radial position corresponds to a position nearer the centre of the bowl and therefore a lower height.
In cartesian coordinates you would probably need a damped harmonic oscillator equation for each of the $x$- and $y$-coordinates. The change in $z$ could then be determined in the some way as above. 
Alternatively, as opposed to having an educated guess at the equations of motion as described above, you could derive them 'from scratch' by considering the potential and kinetic energy exchange (again for each coordinate individually.) If you did this in a vector formalism (using the coordinate system of your choice) you would just have to solve the equations for the velocity $\vec{v}(t)$, then integrate to find the position $\vec{x}(t)$. Again though, you would also need an additional term to account for the loss of energy due to friction. (Otherwise the ball's speed will not decay and therefore neither will its 'orbit'.)
Once you've got your dynamics set up for the motion of a zero-radius ball (a point I guess,) you can then program a modification to adjust how the ball is displayed so that it looks like an object of the desired size. One option would be (for a ball of radius r) to display the point as moving around a constant distance r higher than the surface of the bowl, then program a few lines to depict the ball as an object extended by the distance r around the point. How complex this gets depends on how realistic you want it to appear.
Edit: In your question you refer to "rotation angle" and "position" - if I understand you correctly, you mean the initial position and velocity of the ball. These values would be put in by the programmer or program user as initial conditions, after which the dynamics equations would evolve the system.
