How can i rotate a 2d shape by setting custom pivot anywhere within shape (centre to any corner)

32 Views Asked by At

Is there a simple math formula that let us rotate a shape/points/2d jagged array by lets say setting a pivot point on it (from centre, to any corner) like a graphic design tool and then rotate it at 90 degree, and same formula should work if we keep rotating it

What i learned from cartesian is that we have to remember signs + order of x,y which changes based on we are rotating from 90 to 180 or 270 etc

So is there a better simpler way? I searched on youtube and found one in computer graphics which uses trignometry but its still very complex

Update 2:

Imagine, I have a Rectangle shape based on 4 points, and i want to rotate this triangle to 90 degree where rectangle's centre will be pivot, so ideally i should use same exact math formula that let me rotate on 90 again n again so it goes from 0 to 90 to 180 etc

points example

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

Representing your $(x,y)$ points as complex numbers $x+iy$ makes rotation easy. To rotate a figure by angle $\theta$ around a center point $c$, translate it so that $c$ is at the origin (i.e. subtract $c$ from each point), then multiply by $e^{i\theta}=\cos\theta+i\sin\theta$, then translate back (i.e. add $c$).