Calculate the new $x$, and $y$ coordinates of a scaled rotated rectangle

programmingrectanglesrotationstrigonometryvectors

I want to scale a rotated rectangle around it's centre point and find the new $x$ and $y$ coordinates – In this diagram given I know $(x, y), \theta , w , h , nw$, and $nh$ – does anyone ideas how I calculate $(nx, ny)$?

I'm not massively familiar with vector math or vector notation so please bear with me.

Updated diagram including axis for clarification

EDIT: Sorry, I've updated the diagram to show the rotation origin is not (0,0) – it is unknown.

Best Answer

This assumes the center has coordinates (0,0). The op does not specify where the origin is actually, and which way x and y point to.

Split the path to the corner into two vectors (blue and red) and take their horizontal and vertical projections

fig1

$$ \begin{aligned} x &= x_1 - x_2 \\ y & = y_1 + y_2 \\ \end{aligned} $$

I have marked the congruent angles (same measure) in order to find that

$$ \begin{aligned} x_1 & = \left( \tfrac{h}{2} \right) \sin \theta \\ y_1 & = \left( \tfrac{h}{2} \right) \cos \theta \\ x_2 & = \left( \tfrac{w}{2} \right) \cos \theta \\ y_2 & = \left( \tfrac{w}{2} \right) \sin \theta \end{aligned}$$

Now you can put it all together.