Geometrical calculation to enlarge the height of rotated rectangle

144 Views Asked by At

There is a polygon (rotated rectangle) that defined by 4 corner points in 2D coordinate system. Does anyone help me with the fast (minimum trigonometry operations) algorithm to change its height by any scale factor.

A, B, C, D is known. Need to find A1, B1, C1, D1.


UploadedFig


2

There are 2 best solutions below

0
On

Why not just ($s=$ scale factor): $$A_1=s(A-D)+ D$$ $$D_1=s(D-A)+ A$$ and similarly for $B_1$ and $C_1$.

4
On

Step 1: compute a vector from, for example, $\vec{DA}$

Step 2: divide the vector by it's length (hint: pythagoras theorem) and multiply by desired height

Step 3: add the vector to A, B, and substract it from D, C

Joseph O'Rourke's answer is computationally faster !