定义:
1.旋转:绕原点旋转,逆时针旋转为正,旋转角度为\[\theta \]
2.平移:平移向量为\[({x_0},{y_0})\]
旋转矩阵:
1.点旋转:
\[{P_{rot}} = \left[ {\begin{array}{*{20}{c}}
{\cos \theta }&{-\sin \theta }&0\\
{\sin \theta }&{\cos \theta }&0\\
0&0&1
\end{array}} \right]P\]
\[P = \left[ {\begin{array}{*{20}{c}}
x\\
y\\
1
\end{array}} \right]\]
2.曲线C旋转:
曲线C为:
\[A{x^2} + Bxy + C{y^2} + Dx + Ey + F = 0\]
\[{\left[ {\begin{array}{*{20}{c}}
x\\
y\\
1
\end{array}} \right]^T}\left[ {\begin{array}{*{20}{c}}
A&{B{\rm{/2}}}&{D{\rm{/}}2}\\
{B{\rm{/2}}}&C&{E{\rm{/2}}}\\
{D{\rm{/}}2}&{E{\rm{/2}}}&F
\end{array}} \right]\left[ {\begin{array}{*{20}{c}}
x\\
y\\
1
\end{array}} \right]{\rm{ = 0}}\]
\[C = \left[ {\begin{array}{*{20}{c}}
A&{B{\rm{/2}}}&{D{\rm{/}}2}\\
{B{\rm{/2}}}&C&{E{\rm{/2}}}\\
{D{\rm{/}}2}&{E{\rm{/2}}}&F
\end{array}} \right]\]
\[\begin{array}{l}
{C_{Rot}} = {R^T}CR\\
R = \left[ {\begin{array}{*{20}{c}}
{\cos \theta }&{\sin \theta }&0\\
{ - \sin \theta }&{\cos \theta }&0\\
0&0&1
\end{array}} \right]
\end{array}\]
平移
\[\begin{array}{l}
{C_{Trans}} = {T^T}CT\\
T = \left[ {\begin{array}{*{20}{c}}
1&0&{ - {x_0}}\\
0&1&{ - {y_0}}\\
0&0&1
\end{array}} \right]
\end{array}\]
实验验证
1.点的旋转(红色是旋转后的)
theta = pi/2; Rot1 = [cos(theta) -sin(theta) 0; sin(theta) cos(theta) 0; 0 0 1;] P = [1,0,1]'; P1 = Rot1 * P; figure plot(P(1),P(2),'bx','linewidth',15) hold on; plot(P1(1),P1(2),'ro','linewidth',15) xlim([-0.5,2]) ylim([-0.5,2]) grid on;
旋转角度90
旋转角度45
2.曲线的旋转和平移(红色是旋转平移后的)
a1 = 3; b1 = 2; C1 = [1/a1.^2 0 0; 0 1/b1.^2 0; 0 0 -1;]; figure(1) syms x y f0=ezplot( C1(1,1)*x^2+ C1(2,2)*y^2 +C1(3,3) + 2*C1(1,2)*x*y + 2*C1(1,3)*x +2*C1(2,3)*y,[-6,6],[-6,6]); set(f0,'Color','b','LineWidth',1.5) hold on; grid on; % 画椭圆1 % 画椭圆1旋转平移 theta = pi/4; Rot = [cos(theta) sin(theta) 0; -sin(theta) cos(theta) 0; 0 0 1;] x0 = 1; y0 = 2; T = [1 0 -x0; 0 1 -y0; 0 0 1;]; C1 = T'*Rot'*C1*Rot*T syms x y f1 = ezplot( C1(1,1)*x^2+ C1(2,2)*y^2 +C1(3,3) + 2*C1(1,2)*x*y + 2*C1(1,3)*x +2*C1(2,3)*y,[-6,6],[-6,6]); set(f1,'Color','r','LineWidth',1.5)