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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -