zoukankan      html  css  js  c++  java
  • [平面几何] 直角坐标系下点/曲线平移与旋转的矩阵计算

    定义:

    1.旋转:绕原点旋转,逆时针旋转为正,旋转角度为[ heta ]

    2.平移:平移向量为[({x_0},{y_0})]

    旋转矩阵:

    1.点旋转:

    [{P_{rot}} = left[ {egin{array}{*{20}{c}}
    {cos heta }&{-sin heta }&0\
    {sin heta }&{cos heta }&0\
    0&0&1
    end{array}} ight]P]

    [P = left[ {egin{array}{*{20}{c}}
    x\
    y\
    1
    end{array}} ight]]

    2.曲线C旋转:

    曲线C为:

    [A{x^2} + Bxy + C{y^2} + Dx + Ey + F = 0]


    [{left[ {egin{array}{*{20}{c}}
    x\
    y\
    1
    end{array}} ight]^T}left[ {egin{array}{*{20}{c}}
    A&{B{ m{/2}}}&{D{ m{/}}2}\
    {B{ m{/2}}}&C&{E{ m{/2}}}\
    {D{ m{/}}2}&{E{ m{/2}}}&F
    end{array}} ight]left[ {egin{array}{*{20}{c}}
    x\
    y\
    1
    end{array}} ight]{ m{ = 0}}]

    [C = left[ {egin{array}{*{20}{c}}
    A&{B{ m{/2}}}&{D{ m{/}}2}\
    {B{ m{/2}}}&C&{E{ m{/2}}}\
    {D{ m{/}}2}&{E{ m{/2}}}&F
    end{array}} ight]]


    [egin{array}{l}
    {C_{Rot}} = {R^T}CR\
    R = left[ {egin{array}{*{20}{c}}
    {cos heta }&{sin heta }&0\
    { - sin heta }&{cos heta }&0\
    0&0&1
    end{array}} ight]
    end{array}]

    平移


    [egin{array}{l}
    {C_{Trans}} = {T^T}CT\
    T = left[ {egin{array}{*{20}{c}}
    1&0&{ - {x_0}}\
    0&1&{ - {y_0}}\
    0&0&1
    end{array}} ight]
    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)
    

  • 相关阅读:
    字母图形
    IBM CEO罗睿兰:科技公司屹立百年的3个秘诀
    Uva 1331
    js 推断字符串是否包括某字符串
    Verilog堵塞赋值与非堵塞赋值
    tabBar颜色改动
    零基础学python-4.2 其它内建类型
    怎样给你的Android 安装文件(APK)瘦身
    Ambari-部署常见问题
    ops
  • 原文地址:https://www.cnblogs.com/LoveBuzz/p/9919233.html
Copyright © 2011-2022 走看看