2
$\begingroup$

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


$\endgroup$
1
$\begingroup$

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$.

| cite | improve this answer | |
$\endgroup$
0
$\begingroup$

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 !

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you! Pythagoras theorem give me vector length, yea... Can you post me any example of vector operations that I need to do? What does "compute a vector from" means? $\endgroup$ – Ilya Jul 30 '15 at 23:21
  • $\begingroup$ $\vec{DA}$ means $(x_1 - x_4)i + (y_1 - y_4)j$ $\endgroup$ – user256916 Jul 30 '15 at 23:22
  • $\begingroup$ Thanx! What do you think about the Joseph O'Rourke's approach? $\endgroup$ – Ilya Jul 30 '15 at 23:26
  • $\begingroup$ It works, use that if you can $\endgroup$ – user256916 Jul 30 '15 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.