My application allows rotating points around a center based on the mouse position. I'm basically rotating points around another point like this:
void CGlEngineFunctions::RotateAroundPointRad( const POINTFLOAT ¢er, const POINTFLOAT &in, POINTFLOAT &out, float angle )
{
//x' = cos(theta)*x - sin(theta)*y
//y' = sin(theta)*x + cos(theta)*y
POINTFLOAT subtr;
subtr.x = in.x - center.x;
subtr.y = in.y - center.y;
out.x = cos(angle)*subtr.x - sin(angle)*subtr.y;
out.y = sin(angle)*subtr.x + cos(angle)*subtr.y;
out.x += center.x;
out.y += center.y;
}
where POINTFLOAT is simply
struct POINTFLOAT {
float x;
float y;
}
The issue is that the points need to be updated on mousemove. I am looking for a way to do this without doing the following:
Store original points
Rotate Original points
Copy result
Show Result
Rotate Original points
Copy result
Show Result....
I feel storing the originals seems messy and uses extra memory. Is there a way, knowing the previous rotation angle and the current one that I can somehow avoid applying the transformation to the original points all the time and just build upon the points i'm modifying?
*the center will never change until mouse up so thats not an issue
Thanks