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:

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

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -