math - Rotate a grid of points in C++ -
if had array of point structs defined as
struct point{ float x; float y; };
how rotate points in array given angle?
as example:
any appreciated!
float x_old = p.x; float y_old = p.y; p.x = x_old * cos(a) - y_old * sin(a); p.y = x_old * sin(a) + y_old * cos(a);
of course, if rotating many points same angle, want save sin & cos, instead of calculating them twice per point.
Comments
Post a Comment