probability theorem for continuous distribution 
Let $C$ be the unit circle $x^2 + y^2 = 1.$ A point $p$ is chosen randomly on the circumference of $C$ and another point $q$ is chosen randomly from the interior of $C$ (these points are chosen independently and uniformly at random over their domains). Let $R$ be the rectangle with sides parallel to the $x-$ and $y-$axes with diagonal $pq.$ What's the probability that no point of $R$ lies outside of $C$?

I know the answer's $\frac{4}{\pi^2}.$ Here's the reasoning. Given a point $p$ with an angle $\theta$ from the positive $x$-axis, one can show that $q = (x,y)$ where $|x|\leq |\cos \theta|$ and $|y| \leq |\sin\theta|$ so the probability that $q$ lies in the right region is $\frac{|2\sin 2\theta|}{\pi}.$ Integrating over all possible values of $\theta$ gives that the desired probability is $\frac{1}{2\pi}\int_0^{2\pi} \dfrac{|2\sin 2\theta|}{\pi}d\theta = \frac{4}{\pi^2}.$

Alternatively, I could compute the volumes of the regions $A=\{(\theta, x,y) : \theta \in [0,2\pi], |x|\leq |\cos\theta|, |y|\leq |\sin \theta|\}$ and $\Omega = \{(\theta, x,y) : \theta \in [0,2\pi], x^2 + y^2 = 1\}.$ Then dividing the volume of $A$ by the volume of $\Omega$ should give the result.


Edit: It seems it's not entirely clear what I'm asking. I'm asking for a formal justification of the above solution. I know how to formally show that a point $q=(x,y)$ satisfies the conditions if $p$ makes an angle $\theta$ with the positive $x$-axis iff $-|\cos \theta|\leq x\leq |\cos\theta|$ and $-|\sin\theta| \leq y\leq |\sin\theta|.$ I also know that the probability $q$ lies in the above region is given by the above result. The thing I'm struggling to justify well is why we have to divide by $2\pi$ at the end. Could I get an answer that at least defines random variables and uses probability density functions to justify the final step or some other formal thing?


I would also like some response as to whether this problem can be further generalized. For example, does the following problem make sense and if so what would be a solution? If it doesn't I presume there are multiple such rectangular prisms?

Now consider the unit sphere $C'$. A point $p$ chosen on the surface and a point $q$ chosen in the interior (these points are chosen uniformly and independently over their domains). What is the probability that no point of the rectangular prism with diagonal $pq$ and whose sides are parallel to the $x,y,z$ axes lies outside of $C'$?
 A: The probability density function (pdf) is:
$$
\rho(\omega)=\lim_{\substack{d\Omega\to0\\ \omega\in d\Omega}}\frac{dP}{d\Omega}
$$
where $dP$ is the probability of the random variable $\omega$ to fall within a particular volume of the sample space $d\Omega$.
The pdf of the event which certainly happened in some point of the sample space satisfies the relation:
$$
\int_{\Omega}\rho(\omega)d\omega=1.
$$
If we know only the general "relative" behavior (the ratio of the probability of the event $\omega$ to that of the event $\omega_0$) $$\rho_r(\omega)=\dfrac{\rho(\omega)}{\rho(\omega_0)}$$ we may restore the pdf simply by the relation:
$$
\rho(\omega)=\frac{\rho_r(\omega)}{\int_{\Omega}\rho_r(\omega)d\omega}.
$$
The important point is the following. The expected value of a function of a random variable is:
$$
\bar f=\int_{\Omega}f(\omega)\rho(\omega)d\omega.
$$
Particularly simple is the pdf of uniform distribution (every point in the sample space is equiprobable):
$$
\rho(\omega)=\frac1{\Omega},
$$
where $\Omega$ is the volume of the whole sample space (it cannot be infinite for uniform distribution).
Let now consider your example. Without loss of generality we assume that the radius of the sphere is 1. Let the coordinates of the first point be:
$$
(x,y,z)=(\sin\theta\cos\phi,\sin\theta\sin\phi,\cos\theta)
$$
where $(\theta,\phi)$ are the spherical coordinates of the same point. The coordinates of the second point $(X,Y,Z)$ have to satisfy:
$$
|X|\le|x|,\quad |Y|\le|y|,\quad |Y|\le|y| 
$$
which results in the volume
$$
V(\theta,\phi)=8|\sin^2\theta\cos\theta\cos\phi\sin\phi|.
$$
To obtain the probability in question we integrate over the coordinate of the first point:
$$
P=\frac1{V_2}\int_S\frac{V(\theta,\phi)}{V_3}\,dS,
$$
where $V_2=4\pi$, $V_3=\frac{4\pi}3$ are the area and the volume of the sphere, respectively, and $dS=\sin\theta\,d\theta\,d\phi$ is the infinitesimal element of the surface.
Combining everything together we have:
$$
P=\frac3{2\pi^2}\int_0^\pi\sin^3\theta|\cos\theta|\,d\theta\int_0^{2\pi}|\sin\phi\cos\phi|\,d\phi=\frac3{2\pi^2}.
$$
In this example $\frac1{V_2}$, $\frac1{V_3}$ are the pdf's of the event that the corresponding point is at a certain point of the surface or volume of the sphere, respectively.
