您可以使用由对象和方法表示的 4 x 4 转换矩阵移动、缩放、旋转和镜像对象。还可以使用该方法创建实体的副本,然后将转换应用于该副本。对象是命名空间的一部分。Matrix3dTransformByGetTransformedCopyMatrix3dGeometry 矩阵的前三列指定比例和旋转。矩阵的第四列是平移向量。下表演示了转换矩阵配置,其中 R = 旋转,T = 平移:
要转换对象,请先初始化对象。您可以使用双精度数组或从表示世界坐标系或用户坐标系的矩阵开始初始化变换矩阵。初始化后,您可以使用对象的函数修改矩阵的缩放、旋转或置换变换。Matrix3dMatrix3d 转换矩阵完成后,使用该方法将矩阵应用于对象。以下代码行演示如何将矩阵 () 应用于对象 ():TransformBydMatrixacObj VB.NET acObj.TransformBy(dMatrix) C# acObj.TransformBy(dMatrix); 旋转矩阵示例下面显示了单个数据数组,用于定义分配给变量的转换矩阵,该矩阵将围绕点 (0, 0, 0) 将实体旋转 90 度。dMatrix
VB.NET使用数据数组初始化转换矩阵,其中包含将对象旋转 90 度的信息。 Dim dMatrix(0 To 15) As Double dMatrix(0) = 0.0 dMatrix(1) = -1.0 dMatrix(2) = 0.0 dMatrix(3) = 0.0 dMatrix(4) = 1.0 dMatrix(5) = 0.0 dMatrix(6) = 0.0 dMatrix(7) = 0.0 dMatrix(8) = 0.0 dMatrix(9) = 0.0 dMatrix(10) = 1.0 dMatrix(11) = 0.0 dMatrix(12) = 0.0 dMatrix(13) = 0.0 dMatrix(14) = 0.0 dMatrix(15) = 1.0 Dim acMat3d As Matrix3d = New Matrix3d(dMatrix) 初始化没有数据数组的转换矩阵,并使用函数返回将对象旋转 90 度的转换矩阵。Rotation Dim acMat3d As Matrix3d = New Matrix3d() Matrix3d.Rotation(Math.PI / 2, _ curUCS.Zaxis, _ New Point3d(0, 0, 0)) C#Initialize a transformation matrix with a data array in which contains the information to rotate an object 90 degrees. double[] dMatrix = new double[16]; dMatrix[0] = 0.0; dMatrix[1] = -1.0; dMatrix[2] = 0.0; dMatrix[3] = 0.0; dMatrix[4] = 1.0; dMatrix[5] = 0.0; dMatrix[6] = 0.0; dMatrix[7] = 0.0; dMatrix[8] = 0.0; dMatrix[9] = 0.0; dMatrix[10] = 1.0; dMatrix[11] = 0.0; dMatrix[12] = 0.0; dMatrix[13] = 0.0; dMatrix[14] = 0.0; dMatrix[15] = 1.0; Matrix3d acMat3d = new Matrix3d(dMatrix); Initialize a transformation matrix without a data array and use the function to return a transformation matrix that rotates an object 90 degrees. Rotation Matrix3d acMat3d = new Matrix3d(); acMat3d = Matrix3d.Rotation(Math.PI / 2, curUCS.Zaxis, new Point3d(0, 0, 0)); Additional examples of transformation matricesThe following are more examples of transformation matrices:
|
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )
GMT+8, 2024-5-19 13:51
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.