how to rotate a polygon along any axis
I need to rotate a simple 2D polygon along any axis (to mimic 3D rotation). The polygon is draw on a canvas using lines (VS 2010). I need to keep track of all coordinates during rotation.
I was able to write code for rotating an hexagone around x or y axis using simple math where theta is the angle from the plane XY axis, Phi from the XZ plane.
(rotating around x axis)
pt.X = ptCentre.X + r * cos(theta);
pt.Y = ptCentre.Y + r * sin(theta) * cos(Phi);
(rotating around y axis)
pt.X = ptCentre.X + r * sin(theta) * cos(Phi);
pt.Y = ptCentre.Y + r * cos(theta);
This will not work for rotating the hexagon at 45 degree angle. I am not able to find the math/code for doing rotations at any angle, not just around x or y axis.