I need to compute the following distance Δd using trigonometry:
The image contains a green and a blue rectangle. Here are the measures:
Width of Green = U
Width of Blue = V
Height of Green and Blue = h
Rotation of Green and Blue along X-axis (clockwise) = θ
Need to compute = Distance between their top-edges after rotation (Δd)
Both rectangles were originally aligned to X-axis and their left edges coincided. Then both were rotated θ degrees clockwise around their centers (represented by faint dotted lines). I'm sure this can be done using trigonometry, but having spent the better part of last 2 days, I haven't been able to solve it.

This problem is best tackled by looking at the two length $h$ segments that cut the rectangles in halves. I'll call these segments $S_1$ and $S_2$.