-2
我有x
和y
數組double
。我旋轉他們的簡單公式旋轉時的轉換點
{
double angle;
if (Form1->Edit2->Text != "") {
// deg to rad
angle = StrToFloat(Form1->Edit2->Text) * (M_PI/180);
} else {
angle = 0;
}
for (int i = 1; i <= Spider.count; i++) {
Spider.x[i] = (Spider.x[i] - Spider.x[0]) * cos(angle) -
(Spider.y[i] - Spider.y[0]) * sin(angle) + Spider.x[0];
Spider.y[i] = (Spider.x[i] - Spider.x[0]) * sin(angle) +
(Spider.y[i] - Spider.y[0]) * cos(angle) + Spider.y[0];
}
Spider.Clear();
Spider.Draw();
}
當角度很小時,它的工作。
但是如果天使更大然後30它不工作(計算不正確)
我使用Borland C++生成器6.
x[0], y[0]
畫布的中心(圖片)
PS如果你把減去,請寫的原因。