matlab实现矩阵的旋转变换

  • 以原点为中心,逆时针旋转角度 θ \theta θ
    x ′ = r c o s ( θ + ϕ ) = r c o s θ c o s ϕ − r s i n θ s i n ϕ = x c o s θ − y s i n θ y ′ = r s i n ( θ + ϕ ) = r s i n θ c o s ϕ + r c o s θ s i n ϕ = x s i n θ + y c o s θ x'=rcos(\theta+\phi)=rcos\theta cos\phi-rsin\theta sin\phi=xcos\theta-ysin\theta \\ y'=rsin(\theta+\phi)=rsin\theta cos\phi+rcos\theta sin\phi=xsin\theta+ycos\theta x=rcos(θ+ϕ)=rcosθcosϕrsinθsinϕ=xcosθysinθy=rsin(θ+ϕ)=rsinθcosϕ+rcosθsinϕ=xsinθ+ycosθ
  • d e t ( A ) = 1 det(A)=1 det(A)=1旋转后图形面积不变
    A = [ c o s θ − s i n θ s i n θ c o s θ ] A=\begin{bmatrix} cos\theta & -sin\theta\\ sin\theta & cos\theta \end{bmatrix} A=[cosθsinθsinθcosθ]
    在这里插入图片描述
x1 = [0;0];
x2 = [1;0];
x3 = [1;1];
x4 = [0;1];
x = [x1,x2,x3,x4,x1];
A = [0.866 -0.5;0.5 0.866];
y = A * x;
plot(x(1,:),x(2,:), 'b')
hold on
plot(y(1,:),y(2,:),'r')
axis([-1 1.5 0 1.5])
grid on

猜你喜欢

转载自blog.csdn.net/xiong_xin/article/details/107129462