Distribution of distance between points on intersecting line segments Let $L_1$ and $L_2$ be two intersecting line segments. Let $\theta$ be the smaller angle of intersection between the two. $L_1$ is divided into segments of length $a$ and $b$ while $L_2$ is divided into segments of length $c$ and $d$ by the point of their intersection (call it $O$). A point $X$ is taken on $L_1$ with uniform probability across its length and another one, $Y$ on $L_2$ with the same probability distribution. Let $Z$ be the distance between these two points. How do we calculate the probability density function for $Z$. From what I can figure out, if $X$ and $Y$ are such that $\angle XOY$ is acute, then $Z^2 = OX^2 + OY^2 - 2*OX*OY*cos\theta$ and otherwise, $Z^2 = OX^2 + OY^2 + 2*OX*OY*cos\theta$. So perhaps the problem can be broken down into two parts.
$P(Z^2 > z) = P(Z^2 > z | \angle XOY acute) * P(\angle XOY acute) + P(Z^2 > z | \angle XOY obtuse) * P(~ \angle XOY obtuse)$. 
I can't really understand how do I proceed further or if there is a simpler way from scratch.   
 A: Write the segments in parametric form, $\vec a+\lambda\vec x$ and $\vec b+\mu\vec y$ with $\lambda,\mu\in[0,1]$. Then the distance squared is
$$
d^2=\left(\vec a-\vec b+\lambda\vec x-\mu\vec y\right)^2\;,
$$
and the density of $d^2$ is
$$
f_{d^2}\left(d^2\right)=\int_0^1\mathrm d\mu\int_0^1\mathrm d\lambda\,\delta\left(\left(\vec a-\vec b+\lambda\vec x-\mu\vec y\right)^2-d^2\right)\;.
$$
You can perform the inner integration using the rules for composition of a delta distribution with a function:
$$
f_{d^2}\left(d^2\right)=\sum_i\int_{\mu_{0i}\left(d^2\right)}^{\mu_{1i}\left(d^2\right)}\frac{\mathrm d\mu}{2\vec x\left(\vec a-\vec b+\lambda_i\left(\mu,d^2\right)\vec x-\mu\vec y\right)}{}\;,
$$
where $\lambda_i\left(\mu,d^2\right)$ are the roots of the argument of the delta distribution and $\mu_{0i}\left(d^2\right)$ and $\mu_{1i}\left(d^2\right)$ are the limits up to which these roots exist and lie in $[0,1]$.
The integral doesn't look very promising, since the $\lambda_i$ are roots of a quadratic equations and thus contain square roots; but depending on your application you might use numerical quadrature.
