In the image below there are two rectangles of known width (w) and height (h), that rotate by a known angle (a) around their centres. I need to solve for n.
I've tried the following on squares:
n = sqrtf(powf(w, 2.0f) + powf(w, 2.0f))/2;
and where ang equals the transform angle:
n = (h-w) * (fabsf(ang) / 90) / 2;
but both attempts fail between angles 0 and -90.
I've considered calculating all the angles (e.g. b) within the triangle of n, but without knowing any of the lengths I'm struggling. I need the equation for a swiping animation in a mobile app.
w = 320
h = 568
a = -20
EDIT: I've included a second image to show the changing shape of the triangle to a quadrilateral to a rectangle (at 90 degrees). Is it fair to assume the solution would need to include more than just triangle trig?

