So I'm trying to derive the value of point (p, q) and the rotation value r in terms of the other variables, and I'm having a hard time figuring out how to get there. It's been over 10 years since I took trig and I'm not sure how best to go about tackling this one. The rotated box is a CALayer, and I have previously figured out how to make it work when I used (x, (y + height)) as the layer's (0, 0) anchor point and rotated from the corner down, but now that I'm trying to use the default center (0.5, 0.5) as the anchor, I'm having a hard time figuring out the math. The reason for wanting to use the center for my anchor point is so when I apply layer transformations to my layer (such as scaling) the effect is properly centered on the layer instead of being skewed to the side. I should mention that although I've drawn my layer as a square, the height of my layer can be arbitrarily defined to any reasonably sized positive value (obviously the width is necessarily determined by the pythagorean theorem). I hope I was able to clearly explain the problem, and I appreciate any help you could send my way.