If i had an array of point structs defined as
struct Point{
float x;
float y;
};
How would I rotate the points in this array by a given angle?
As an example:
Any help would be 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 you are rotating many points by the same angle, you will want to save the sin & cos, instead of calculating them twice per point.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.