A rectangular bar is pivoted at point P, the bar can rotate freely about this pivot point P.
A ball with radius $R$ (here shown as a circle for simplicity) can only move/slide in the x-axis direction. As the ball collides with the bar, the bar starts moving about the pivot point P. The side of the bar touching the sphere must always be tangent to the sphere/circle.
At all points I have the coordinates of the center of the sphere/circle, but I fail to find the angle that will make sure the bar stays tangential to the surface of the ball.
I kind of need an equation I can put the coordinates of the sphere and/or the pivot etc. and the equation tells me the angle I need to rotate the bar by so as to make sure the bar stays tangential to the ball. In case you need additional information (such as thickness of the bar for instance, please assume a constant)

Let $r$ be the radius of the ball, $k$ the thickness of the bar and $d$ be the distance from the center of the ball to the pivot point. An equivalent problem would be to think of the angle of a line (rather than a bar) tangent to a circle of radius $r+\frac{k}{2}$ instead. In this equivalent problem, the line touches the ball at $A$ and we can think of a right triangle with vertices at $A$, the ball center and the pivot point. The hypothenuse of this triangle has length $d$, and that of the "radius" leg is $r+\frac{k}{2}.$ Using Pythagoras we can compute the length of the other leg, lets call it $a$. With this information, we can compute the position of $A$ (because we know the distances from the pivot point and from the center of the ball to $A$). The slope of the line that goes through $A$ and the center of the ball is the angle you are looking for.