<s>[INST] Probability of a rectangular card intersecting the lines of a floor I have attempted this problem, but do not understand how the answer was achieved. The question is as follows (coming from Henk Tijms 'Understanding Probability' (3rd edn.) book):

Problem 7.16 
Consider the following variant of Buffon's needle problem. A rectangular card with the side lengths $a$ and $b$ is
  dropped at random on the floor. It is assumed that the length
  $\sqrt{a^2 + b^2}$ of the diagonal of the card is smaller than the
  distance $D$ between the parallel lines on the floor. Show that the
  probability of the card intersecting one of the lines is given by
  $\frac{2(a+b)}{\pi D}$.

I have let $y$ to be the centre of the rectangular card to the closest line of the two, and $x$ be the angle of the diagonal of the card. Thus I have defined the sample space to be $\Omega = \{(x,y): 0 \leq x \leq \pi, 0 \leq y \leq \frac{1}{2}D\}$.
The hypotenuse from the middle of the card to the closest line is then $\frac{y}{\sin(x)}$. If $\frac{y}{\sin(x)} > \frac{1}{2}\sqrt{a^2 + b^2}$ then the card does not touch either of the two lines. So if $\frac{y}{\sin(x)} \leq \frac{1}{2}\sqrt{a^2 + b^2}$ then the card intersects a line of the floor. Thus $y \leq \frac{\sin(x)}{2}\sqrt{a^2 + b^2}$, and so calculating the probability that the card intersects one of the lines is:
$\begin{align} \frac{\int _{0} ^{\pi} {\frac{\sin(x)}{2}\sqrt{a^2 + b^2}}\;dx}{\frac{1}{2}\pi D} &= \frac{\int _{0} ^{\pi} {\sin(x)\sqrt{a^2 + b^2}}\;dx}{\pi D} \\ &= \frac{2\sqrt{a^2 + b^2}}{\pi D} \end{align}$
I'm not sure if I skipped something or made some error here, but thank you in advance for your help.
 [/INST] I think the problem is the range of integration for $x$. Assume WLOG that $a\leq b$. There being two diagonals and thus two choices for $x$, we want $x$ to be the angle between a diagonal and the parallel lines that is closest to a right-angle. Then we have $\theta\leq x\leq \theta+\pi/2$ where $\theta$ is the angle between either diagonal and the long side of the rectangle. When the long side of the rectangle is parallel with the parallel lines, $x=\theta$; when the long side is perpendicular to the parallel lines, $x=\theta+\pi/2.$
It's easy to calculate $\theta=\tan^{-1}\left(a/b\right)$.
So the sample space is 
$$\Omega = \left\{(x,y)\;:\; \theta\lt x\lt \theta+\frac{\pi}{2},\; 0\lt y\lt \frac{D}{2} \right\}.$$
Now, $x,y$ are independent and uniformly distributed over their range so their density functions are:
$$f_X(x) = \dfrac{2}{\pi} \\ f_Y(y) = \dfrac{2}{D}.$$
And as you found, the region where the card intersects a line satisfies
$$y \lt \dfrac{1}{2}\sqrt{a^2+b^2}\sin{x}.$$
So for the required probability, we integrate as follows
\begin{eqnarray*}
P(\text{intersection}) &=& \int_{x=\theta}^{\theta+\pi/2} \dfrac{2}{\pi} \int_{y=0}^{\frac{1}{2}\sqrt{a^2+b^2}\sin{x}} \dfrac{2}{D}\;dydx \\
&=& \int_{x=\theta}^{\theta+\pi/2} \dfrac{2}{\pi D} \sqrt{a^2+b^2}\sin{x} \;dx \\
&=& \dfrac{2}{\pi D} \sqrt{a^2+b^2}\;\bigg[-\cos{x} \bigg]_{\theta}^{\theta+\pi/2} \\
&=& \dfrac{2}{\pi D} \sqrt{a^2+b^2}\;\left(\cos{\theta} + \sin{\theta} \right) \qquad\qquad\text{(using basic trig identities)} \\
&=& \dfrac{2}{\pi D} \sqrt{a^2+b^2}\;\left(\dfrac{b}{\sqrt{a^2+b^2}} + \dfrac{a}{\sqrt{a^2+b^2}} \right) \\
&=& \dfrac{2(a+b)}{\pi D}.
\end{eqnarray*}
</s>