@arthur99,
Here's how I would do it. (Might not be the easiest way.) Let's first consider your original problem of two rectangles in a larger rectangle. If I reduce it to one dimension, the problem becomes if I have two line segments L1 and L2 on a longer segment L, what is the probability that the two segments do not interact. If we assume the first segment starts at point x, the probability P that the second segment will not interact with the first segment is
P = (x-L2)/(L-L2)
To find the total one dimensional probability for all values x, integrate P over the range L2 to L-L1 and divide the result by (L-L1) which is the range for possible x's. (For x<L2, the probability is zero, x cannot be greater than L-L1 since the first segment must fit in the overall length.)
This is a simple integration leaving you with
Code: (L^2/2 + L1^2/2 + L2^2/2 - LL2 - LL1 + L1L2)
--------------------------------------------------
(L-L1)(L-L2)
This is the probability that segment two is to the left of segment one. The probability that segment one is to the left of segment two yields the same result and is mutually exclusive, so the total probability that the X axis segments do not overlap is 2x this equation or:
Code: (L^2 + L1^2 + L2^2 - 2LL2 - 2LL1 + 2L1L2)
P = ---------------------------------------------
(L-L1)(L-L2)
Now that you have the one dimensional solution, you need the two dimensional solution. In order for the two rectangles to have an overlap, they must overlap on
both the X and Y axes. So you use the above equation on both axes and take Pt = 1 - (1-Px)(1-Py)
Now for the variable pencil. The probability for the pencil will change depending on how it falls. The L2x and W2y (width on the other axis) values for the pencil are Lp (length of pencil) cos(angle) and Lp sin(angle). If you integrate the total probability function over 0 to 2pi and divide by 2pi you can get the total probability.