How to get the value of X and Y after changing the angle

61 Views Asked by At

I drew this picture to interpret my question.

1 2

I have an object that will initially be at X: 0 Y: 0 with an angle of , being 70 wide and 100 high. I need to obtain the new value of the X and Y axis after this same object is rotated to an angle of 45º.

How can I get this value, since the correct value would be X: -25.1 and Y: 39.39

1

There are 1 best solutions below

0
On BEST ANSWER

Everything you wanted to know about a rotated rectangle of size $(a,b)$, and its bounding box.

fig1

In the example above the rectangle is rotated by a counter-clockwise angle of $\theta$.

$$\begin{aligned}y & =a\sin\theta\\ x & =b\sin\theta\\ w & =a|\cos\theta|+b|\sin\theta|\\ h & =a|\sin\theta|+b|\cos\theta| \end{aligned}$$

where $|\cdot|$ is the absolute value.

If the angle is negative then use the same equations as above but the definitions of $(x,y)$ offsets is a bit different (see below).

fig2


Also note that a point $(a,b)$ rotated by a CCW angle $\theta$ has coordinates $$ {\rm rot}\left(\pmatrix{a\\b},\theta\right)=\pmatrix{a\cos\theta-b\sin\theta\\a\sin\theta+b\cos\theta} $$