Find the center-coordinates of a rotated rectangle

593 views Asked by At

I am having trouble with finding the X and Y-coordinates of the center of a rotated rectangle through mathematical calculations. What I have is the width 'A' and height 'B' of a rectangle, as well as its rotation 'R' in degrees. What would be the formula to calculate those points? Here is a sketch to further explain what i am trying to do: enter image description here

Any help is greatly appreciated! :)

2

There are 2 answers

3
Tareq Alsayed On

if you are trying to do it in pure way, by your self it think this answer would be great for you https://math.stackexchange.com/questions/270194/how-to-find-the-vertices-angle-after-rotation

if you want to use a package for this, then I do recommend flatten-js , geometric ,Ecluid.ts

1
AudioBubble On

I doubt that this is what you are after, but here is a solution to a possibly related question.

We assume that the leftmost corner lies on the Y axis, and the bottommost on the X axis. Thus, the coordinates of these corners are (0, B sin R) and (B cos R, 0) respectively. The midpoint of the bottom side is (B/2 cos R, B/2 sin R). To this we add a vector of length A/2 in the orthogonal direction and obtain the coordinates of the center:

(B/2 cos R - A/2 sin R, B/2 sin R + A/2 cos R)