Reputation: 456
I'm trying to find a way to rotate an arbitrary polygon around its own geometric center. It was drawn in a blackboard built with creating js.
I've been trying many approaches, but any of them has worked.
How can I accomplish it?
Upvotes: 0
Views: 177
Reputation: 313
Find the geometric centre as the average of all the points' coordinates. Make all the points relative to this centre (such that the centre is (0,0)
), then rotate them by the desired angle using a rotation matrix. You can then draw using these points.
This is assuming you have the coordinates of all the points.
Upvotes: 1