我的应用程序允许基于鼠标位置围绕中心旋转点。我基本上旋转点周围像这样的另一点:该问题的帮助
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;
}
其中POINTFLOAT简直是
struct POINTFLOAT {
float x;
float y;
}
的问题是,该点需要鼠标移动上进行更新。我正在寻找一种方式来做到这一点而不做以下:
Store original points
Rotate Original points
Copy result
Show Result
Rotate Original points
Copy result
Show Result....
我觉得存储原件似乎凌乱和使用额外的内存。有没有办法,知道前一个旋转角度和当前的旋转角度,我可以避免将变换始终应用于原始点,并且仅仅基于我正在修改的点?
*中心将永远不会改变,直到鼠标抬起所以那不是一个问题
感谢
每当我看到一个问题,标记C和C++我的头想要爆炸 – James 2010-08-17 15:35:47
将头[[explode()'](http://php.net/manual/en/function.explode.php)如果它被标记为[c,C++和php](http://stackoverflow.com/questions/tagged/c%20c%2b%2b%20php)? :p – kennytm 2010-08-17 15:38:18
此外,这似乎是一个基于数学的问题,即可能在math.stackexchange上找到更好的答案。 – James 2010-08-17 15:38:49