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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -