3d transform

来源:互联网 发布:剑网三淘宝买金哪家 编辑:程序博客网 时间:2024/06/04 23:21



=============================================================
Translation:
        (1  0  0  0)
    T = (0  1  0  0)
        (0  0  1  0)
        (Tx Ty Tz 1)
    [x' y' z' 1] = [x y z 1].T

=============================================================
Scaling:
        (Sx 0  0  0)
    S = (0  Sy 0  0)
        (0  0  Sz 0)
        (0  0  0  1)
    [x' y' z' 1] = [x y z 1].S

=============================================================
Rotation_Right Hand Coordinate:

    by x axis:
                (1   0     0    0)
        Rx(q) = (0  cosq -sinq  0)
                (0  sinq  cosq  0)
                (0   0    0     1)
        [x' y' z' 1] = [x y z 1].Rx(q)

        x' = x
        y' = z*sinq + y*cosq
        z' = z*cosq -y*sinq

    by y axis:
                (cosq  0  sinq   0)
        Ry(q) = (0     1   0     0)
                (-sinq 0  cosq   0)
                (0     0   0     1)
        [x' y' z' 1] = [x y z 1].Ry(q)

        x' = x*sinq + z*cosq
        y' = y
        z' = x*cosq - z*sinq

    by z axis:
                (cosq -sinq  0  0)
        Rz(q) = (sinq  cosq  0  0)
                (0      0    1  0)
                (0      0    0  1)
        [x' y' z' 1] = [x y z 1].Rz(q)
     
        x' = y*sinq + x*cosq
        y' = y*cosq - x*sinq
        z' = z

=============================================================
Rotation_Left Hand Coordinate

    by x axis:
                (1   0     0    0)
        Rx(q) = (0  cosq  sinq  0)
                (0 -sinq  cosq  0)
                (0   0     0    1)
        [x' y' z' 1] = [x y z 1].Rx(q)

        x' = x
        y' = y*cosq - z*sinq
        z' = y*sinq + z*cosq

    by y axis:
                (cosq  0 -sinq  0)
        Ry(q) = (0     1   0    0)
                (sinq  0 cosq   0)
                (0     0   0    1)
        [x' y' z' 1] = [x y z 1].Ry(q)

        x' = z*sinq + x*cosq
        y' = y
        z' = z*cosq - x*sinq


    by z axis:
                (cosq  sinq  0  0)
        Rz(q) = (-sinq cosq  0  0)
                (0      0    1  0)
                (0      0    0  1)
        [x' y' z' 1] = [x y z 1].Rz(q)

        x' = x*cosq - y*sinq
        y' = x*sinq + y*cosq
        z' = z

0 0