马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 csharp 于 2014-5-2 17:01 编辑
- //Matrix3d 转换为 ResultBuffer
- static ResultBuffer Matrix3dToesultBuffer(Matrix3d matrix3D)
- {
- ResultBuffer result = new ResultBuffer();
- Double [] arrays = matrix3D.ToArray();
- int count = 0;
- result.Add(new TypedValue((int)LispDataType.ListBegin));
- for (int i = 0; i < 4; i++)
- {
- result .Add( new TypedValue((int)LispDataType .ListBegin ));
- for (int j = 0; j < 4; j++)
- {
- result.Add(new TypedValue((int)LispDataType.Double, arrays[count]));
- count++;
- }
- result.Add(new TypedValue((int)LispDataType.ListEnd ));
- }
- result.Add(new TypedValue((int)LispDataType.ListEnd));
- return result;
- }
- //Wcs 到当前 Ucs 转换矩阵
- static Matrix3d GetUcsMatrix()
- {
- Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
- Matrix3d mat = ed.CurrentUserCoordinateSystem;
- return mat;
- }
- //单位矩阵
- [LispFunction("Matrix_identity")]
- public static ResultBuffer MatrixIdEntity(ResultBuffer rb)
- {
- Matrix3d matrix3D = new Matrix3d();
- matrix3D = Matrix3d.Identity;
- return Matrix3dToesultBuffer(matrix3D);
- }
- //Wcs 到当前 Ucs 转换矩阵
- [LispFunction("Matrix_Wcs2Ucs")]
- public ResultBuffer MatrixWcs2Ucs(ResultBuffer rb)
- {
- Matrix3d mat = GetUcsMatrix();
- return Matrix3dToesultBuffer(mat);
- }
- //当前 Ucs 到 Wcs 转换矩阵
- [LispFunction ("Matrix_Ucs2Wcs")]
- public ResultBuffer MatrixUcs2Wcs(ResultBuffer rb)
- {
- Matrix3d mat = GetUcsMatrix();
- return Matrix3dToesultBuffer(mat.Inverse() );
- }
命令: (matrix_ucs2wcs)
((0.763333 0.646005 0.0 -2411.89) (-0.646005 0.763333 0.0 496.264) (0.0 0.0 1.0 0.0) (0.0 0.0 0.0 1.0))
命令: (matrix_wcs2ucs)
((0.763333 -0.646005 0.0 2161.66) (0.646005 0.763333 0.0 1179.28) (0.0 0.0 1.0 0.0) (0.0 0.0 0.0 1.0))
命令: (matrix_identity)
((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)) |