打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
about transaxis
Matrix routines

Because matrices are rather large when expressed in text form, the following definitions are used for the examples.

  • transidentity - Returns the identity matrix.
    Example:vmd > transidentityInfo) {1.0 0.0 0.0 0.0} {0.0 1.0 0.0 0.0} {0.0 0.0 1.0 0.0} {0.0 0.0 0.0 1.0}

  • transtranspose m - Returns the matrix transpose of the given matrix
    Example:vmd > transtranspose {{0 1 2 3 4} {5 6 7 8} {9 10 11 12} {13 14 15 16}}Info) {0 5 9 13} {1 6 10 14} {2 7 11 15} {3 8 12 16}

  • (C++) transmult m1 m2 [m3 ... mn] - Returns the matrix multiplication of the given matrices
    Examples:vmd > set mat1 {{1 2 3 4} {-2 3 -4 5} {3 -4 5 -6} {4 5 -6 -7}}vmd > set mat2 {{1 0 0 0} {0 0.7071 -0.7071 0} {0 0.7071 0.7071 0} {0 0 0 1}}vmd > set mat3 {{0.866025 0 0 0} {0 1 0 0} {-0.5 0 0.866025 0} {0 0 0 1}}vmd > transmult $mat1 [transidentity]Info) {1.0 2.0 3.0 4.0} {-2.0 3.0 -4.0 5.0} {3.0 -4.0 5.0 -6.0}    {4.0 5.0 -6.0 -7.0}vmd > transmult $mat1 $mat2 $mat3Info) {0.512475 3.5355 0.612366 4.0} {0.7428 -0.7071 -4.28656 5.0}   {-0.58387 0.7071 5.5113 -6.0} {7.35315 -0.7071 -6.73603 -7.0}

  • transaxis
    x|y|z
    amount [deg|rad|pi]
    - Returns the transformation matrix needed to rotate around the specified axis by a given amount. By default, the amount is specified in degrees, though it can also be given in radians or factors of pi.
    Examples:vmd > transaxis x 90Info) {1.0 0.0 0.0 0.0} {0.0 -3.67321e-06 -1.0 0.0} {0.0 1.0 -3.67321e-06 0.0}         {0.0 0.0 0.0 1.0}vmd > transaxis y 0.25 piInfo) {0.707107 0.0 0.707107 0.0} {0.0 1.0  0.0 0.0}          {-0.707107 0.0 0.707107 0.0} {0.0 0.0  0.0 1.0}vmd > transaxis z 3.1415927 radInfo) {-1.0 -2.65359e-06 0.0 0.0} {2.65359e-06 -1.0 0.0 0.0} {0.0 0.0 1.0 0.0}         {0.0 0.0 0.0 1.0}

  • transvec v - Returns the transformation matrix needed to bring the x axis along the v vector. This matrix is not unique, since a final rotation is allowed around the vector. The matrix is made from a rotation around y, then one about z.
    Examples:vmd > transvec {0 1 0}Info) {-3.67321e-06 -1.0 0.0 0.0} {1.0 -3.67321e-06 0.0 0.0} {0.0 0.0 1.0 0.0}         {0.0 0.0 0.0 1.0}vmd > vectrans [transvec {0 0 2}] {1 0 0}Info) 0.0 0.0 1.0

  • transvecinv v - Returns the transformation needed to bring the vector v to the x axis. This produces the inverse matrix to transvec, and is composed of a rotation about z then one about y.
    Examples:vmd > transvecinv {0 -1 0}Info) {-3.67321e-06 -1.0 0.0 0.0} {1.0 -3.67321e-06 0.0 0.0} {0.0 0.0 1.0 0.0}    {0.0 0.0 0.0 1.0}vmd > vectrans [transvecinv {-3 4 -12}] {-3 4 -12}Info) 13.0 -1.8e-05 5.8e-05vmd > transmult [transvec {6 -5 7}] [transvecinv {6 -5 7}]Info) {0.999999 2.29254e-07 -6.262e-09 0.0} {2.29254e-07 0.999999    -4.52228e-07 0.0} {-6.262e-09 -4.52228e-07 1.0 0.0} {0.0 0.0 0.0 1.0}

  • (C++) transoffset v - Returns the transformation matrix needed to translate by the given offset
    Examples:vmd > transoffset {1 0 0}Info) {1.0 0.0 0.0 1} {0.0 1.0 0.0 0} {0.0 0.0 1.0 0} {0.0 0.0 0.0 1.0}vmd > transoffset {-6 5 -4.3}Info) {1.0 0.0 0.0 -6} {0.0 1.0 0.0 5} {0.0 0.0 1.0 -4.3} {0.0 0.0 0.0 1.0}

  • transabout v amount [deg|rad|pi] - Generates the transformation matrix needed to rotate by the given amount counter-clockwise around axis which goes through the origin and along the given vector. As with transvec, the units of the amount of rotation can be degrees, radians, or multiples of pi.
    Examples:# this is a rotation about x by 180 degreesvmd > transabout {1 0 0} 180Info) {1.0 0.0 0.0 0.0} {0.0 -1.0 -2.65359e-06 0.0} {0.0 2.65359e-06        -1.0 0.0} {0.0 0.0 0.0 1.0}# a rotation about z by 90 degrees# (compare this to "transaxis z 90"vmd > transabout {0 0 1} 1.5709 radInfo) {0.999624 -0.027414 0.0 0.0} {0.027414 0.999624 0.0 0.0}         {0.0 0.0 1.0 0.0} {0.0 0.0 0.0 1.0}vmd > transabout {1 1 1} 1 piInfo) {-0.333335 0.666665 0.666669 0.0} {0.666668 -0.333334 0.666666        0.0} {0.666666 0.66667 -0.333332 0.0} {0.0 0.0 0.0 1.0}

  • trans [center {x y z}] [origin {x y z}] [offset {x y z}] [axis x amount [rad|deg|pi]] [axis y amount [rad|deg|pi]] [axis z amount [rad|deg|pi]] [x amount [rad|deg|pi]] [y amount [rad|deg|pi]] [z amount [rad|deg|pi]] [axis {x y z} amount [rad|deg|pi]] [bond {x1 y1 z1} {x2 y2 z2} amount [rad|deg|pi]] [angle {x1 y1 z1} {x2 y2 z2} {x3 y3 z3} amount [rad|deg|pi]] -

    This command can do almost everything the other ones can do, and then some. It is designed to be the main function used for generating transformation matrices.

Using it correctly calls for understanding how it works internally. There are three matrices: centering, rotation, and offset. The centering matrix determines where the center of rotation is located. By default, this is the origin, but it can be changed to pivot about any point. The rotation matrix defines the rotation about that centering point, and the offset matrix defines the final translation after the rotation.

For example, to rotate around a given point, the transformations would be 1) the centering matrix to bring that point to the origin, 2) the rotation about the center, and 3) the final offset to return the origin back to its original location.

The different options for the trans command modify the matrices in various ways.

-

  • center {x y z} - Sets the centering matrix so that point x y z is brought to the origin
  • offset {x y z} - Sets the offset matrix so that the origin is brought to x y z
  • origin {x y z} - Sets both the centering and offset matrices to x y z

  • axis x amount [rad|deg|pi] - Adds a rotation about the x axis by the given amount to the rotation matrix

  • axis y amount [rad|deg|pi] - Adds a rotation about the y axis by the given amount to the rotation matrix

  • axis z amount [rad|deg|pi] - Adds a rotation about the z axis by the given amount to the rotation matrix

  • axis {x y z} amount [rad|deg|pi] - Adds a rotation of the given amount about the given vector to the rotation matrix

  • bond {x1 y1 z1} {x2 y2 z2} amount [rad|deg|pi] - Sets the center and offset transformations to the first point, and defines a rotation about the bond axis by the given amount.

  • angle {x1 y1 z1} {x2 y2 z2} {x3 y3 z3} amount [rad|deg|pi] - Sets the center and offset transformation to the second point, and defines a rotation about the axis perpendicular to the plane made by the three points (the vector is computed from the cross product of the vector connecting the first two points with that connected the last two).



Next: Multiplying vectors and matrices Up: Vectors and Matrices Previous: Vectors Contents Index
vmd@ks.uiuc.edu
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
Maya特效教程:Maya用particle的instancer模拟帆船
TweenMax CSSPlugin文档
Slippy map tilenames(瓦片和经纬度换算)
Excel VBA在工程测量上的应用_水利工程网
Euler angles - Wikipedia, the free encyclopedia
使用Python进行立体几何和立体校正的综合教程
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服