圖像旋轉(zhuǎn)是指把定義的圖像繞某一點(diǎn)以逆時(shí)針或順時(shí)針?lè)较蛐D(zhuǎn)一定的角度,通常是指繞圖像的中心以逆時(shí)針?lè)较蛐D(zhuǎn)。
逆時(shí)針-θ
假設(shè)圖像的左上角為(left, top),右下角為(right, bottom),則圖像上任意點(diǎn)(x0, y0)繞其中心(xcenter, ycenter)順時(shí)針旋轉(zhuǎn)θ角度后,新的坐標(biāo)位置(x′, y′)的計(jì)算公式為:
xcenter = (right - left + 1) / 2 + left;
ycenter = (bottom - top + 1) / 2 + top;
x′ = (x0 - xcenter) cosθ - (y0 - ycenter) sinθ + xcenter;
y′ = (x0 - xcenter) sinθ + (y0 - ycenter) cosθ + ycenter;
逆時(shí)針-θ