首页 > 其他分享 >AutoCAD.NET:矩阵和变换–矩阵信息

AutoCAD.NET:矩阵和变换–矩阵信息

时间:2023-04-14 09:44:46浏览次数:58  
标签:Matrix3d AutoCAD matrix Vector3d ed 矩阵 WriteMessage nThe NET

 

 

[CommandMethod("Matrix_PrintOut")]
public static void Matrix_PrintOut()
{
Editor ed = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
try
{
Matrix3d identityMatrix = Matrix3d.Identity; //单位矩阵
ed.WriteMessage("\nThe identity matrix is: \n{0}\n", identityMatrix );

Plane plane = new Plane(new Point3d(10, 0, 0), new Vector3d(1, 1, 1));
Point3d point1 = new Point3d(5, 3, 1);
Point3d point2 = new Point3d(10, 20, 30);
Vector3d normal = new Vector3d(1, 2, 3);
Vector3d vector = new Vector3d(10, 10, 10);
//移动矩阵
Matrix3d movementMatrix = Matrix3d.Displacement(vector);
ed.WriteMessage("\nThe movement matrix is: \n{0}\n", movementMatrix);
//旋转矩阵 Matrix3d rotationMatrix = Matrix3d.Rotation(Math.PI / 4, Vector3d.ZAxis, point1);
ed.WriteMessage("\nThe rotation matrix is: \n{0}\n", rotationMatrix);
//绕原点缩放矩阵 Matrix3d scaleAroundOriginMatrix = Matrix3d.Scaling(2, Point3d.Origin);
ed.WriteMessage("\nThe scaleAroundOrigin matrix is: \n{0}\n", scaleAroundOriginMatrix);
//绕点pt1旋转矩阵 Matrix3d scaleAroundPointMatrix = Matrix3d.Scaling(2, point1);
ed.WriteMessage("\nThe scaleAroundPoint matrix is: \n{0}\n", scaleAroundPointMatrix);
//点镜像矩阵 Matrix3d pointMirrorMatrix = Matrix3d.Mirroring(point1);
ed.WriteMessage("\nThe pointMirror matrix is: \n{0}\n", pointMirrorMatrix);
//线镜像矩阵 Matrix3d lineMirrorMatrix = Matrix3d.Mirroring(new Line3d(point1, point2));
ed.WriteMessage("\nThe lineMirror matrix is: \n{0}\n", lineMirrorMatrix);
//面镜像矩阵 Matrix3d planeMirrorMatrix = Matrix3d.Mirroring(plane);
ed.WriteMessage("\nThe planeMirror matrix is: \n{0}\n", planeMirrorMatrix);
//复合矩阵 Matrix3d compondMatrix = movementMatrix.PostMultiplyBy(rotationMatrix)
.PostMultiplyBy(scaleAroundPointMatrix)
.PostMultiplyBy(lineMirrorMatrix);
ed.WriteMessage("\nThe compond matrix is: \n{0}\n", compondMatrix);
//投影矩阵
Matrix3d projectionMatrix = Matrix3d.Projection(plane, normal);
ed.WriteMessage("\nThe projection matrix is: \n{0}\n", projectionMatrix);
     Matrix3d planeToWorld1 = Matrix3d.PlaneToWorld(plane);
ed.WriteMessage("\nThe planeToWorld1 matrix is: \n{0}\n", planeToWorld1);
     Matrix3d planeToWorld2 = Matrix3d.PlaneToWorld(normal);
ed.WriteMessage("\nThe planeToWorld2 matrix is: \n{0}\n", planeToWorld2);
     Matrix3d worldToPlane1 = Matrix3d.WorldToPlane(plane);
ed.WriteMessage("\nThe worldToPlane1 matrix is: \n{0}\n", worldToPlane1);
    Matrix3d worldToPlane2 = Matrix3d.WorldToPlane(normal);
ed.WriteMessage("\nThe worldToPlane2 matrix is: \n{0}\n", worldToPlane2);

Matrix3d alignmentCS = Matrix3d.AlignCoordinateSystem(
Point3d.Origin,
Vector3d.XAxis,
Vector3d.YAxis,
Vector3d.ZAxis,
point1,
Vector3d.YAxis,
Vector3d.ZAxis,
Vector3d.XAxis);
ed.WriteMessage("\nThe alignmentCS matrix is: \n{0}\n", alignmentCS);
}
catch (System.Exception ex)
{
ed.WriteMessage(ex.ToString());
}
}
Here is the output:

Command: Matrix_PrintOutThe identity matrix is:((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1))The movement matrix is:((1,0,0,10),(0,1,0,10),(0,0,1,10),(0,0,0,1))The rotation matrix is:((0.707106781186547,-0.707106781186548,0,3.58578643762691),(0.707106781186548,0.707106781186547,0,-2.65685424949238),(0,0,1,0),(0,0,0,1))The scaleAroundOrigin matrix is:((2,0,0,0),(0,2,0,0),(0,0,2,0),(0,0,0,1))The scaleAroundPoint matrix is:((2,0,0,-5),(0,2,0,-3),(0,0,2,-1),(0,0,0,1))The pointMirror matrix is:((-1,0,0,10),(0,-1,0,6),(0,0,-1,2),(0,0,0,1))The lineMirror matrix is:((-0.956709956709957,0.147186147186147,0.251082251082251,9.09090909090909),(0.147186147186147,-0.4995670995671,0.853679653679654,2.90909090909091),(0.251082251082251,0.853679653679654,0.456277056277056,-3.27272727272727),(0,0,0,1))The planeMirror matrix is:((0.333333333333333,-0.666666666666667,-0.666666666666667,6.66666666666667),(-0.666666666666667,0.333333333333333,-0.666666666666667,6.66666666666667),(-0.666666666666667,-0.666666666666667,0.333333333333333,6.66666666666667),(0,0,0,1))The compond matrix is:((-1.56114484158069,0.914647213067275,-0.852201419404047,20.9139839881057),(-1.14483955049251,-0.498341921979091,1.56236926890742,18.6568542494924),(0.502164502164502,1.70735930735931,0.912554112554112,2.45454545454545),(0,0,0,1))The projection matrix is:((0.833333333333333,-0.166666666666667,-0.166666666666667,1.66666666666667),(-0.333333333333333,0.666666666666667,-0.333333333333333,3.33333333333333),(-0.5,-0.5,0.5,5),(0,0,0,1))The planeToWorld1 matrix is:((-0.707106781186548,-0.408248290463863,0.577350269189626,10),(0.707106781186548,-0.408248290463863,0.577350269189626,0),(0,0.816496580927726,0.577350269189626,0),(0,0,0,1))The planeToWorld2 matrix is:((-0.894427190999916,-0.358568582800318,0.267261241912424,0),(0.447213595499958,-0.717137165600636,0.534522483824849,0),(0,0.597614304667197,0.801783725737273,0),(0,0,0,1))The worldToPlane1 matrix is:((-0.707106781186548,0.707106781186548,0,7.07106781186548),(-0.408248290463863,-0.408248290463863,0.816496580927726,4.08248290463863),(0.577350269189626,0.577350269189626,0.577350269189626,-5.77350269189626),(0,0,0,1))The worldToPlane2 matrix is:((-0.894427190999916,0.447213595499958,0,0),(-0.358568582800318,-0.717137165600636,0.597614304667197,0),(0.267261241912424,0.534522483824849,0.801783725737273,0),(0,0,0,1))The alignmentCS matrix is:((0,0,1,5),(1,0,0,3),(0,1,0,1),(0,0,0,1))
 
The code and the output here just give some ideas about what kind of transformations (in fact pretty everthing) that the AutoCAD .NET Matrix provides us. In terms of what they really indicate, they will be discussed and demonstrated in coming posts. Please stay tuned.
AutoCAD .NET Addin Wizard (AcadNetAddinWizard) provides many project wizards, item wizards, coders and widgets to help automate AutoCAD conveniently and professionally using the AutoCAD .NET API.
If you find the information/code here is helpful, please make a kind donation. Or if you'd like to make comments to us directly, please feel free to email us.
原文地址:AutoCAD .NET: Matrix & Transformations – Matrix Information - AcadNetAddinWizard & More (typepad.com)

标签:Matrix3d,AutoCAD,matrix,Vector3d,ed,矩阵,WriteMessage,nThe,NET
From: https://www.cnblogs.com/wfkgitee/p/17317314.html

相关文章

  • 【转】基于.net6+gtksharp实现的Linux下的图形界面串口调试工具
    【开源】基于.net6+gtksharp实现的Linux下的图形界面串口调试工具-狼性法则-博客园(cnblogs.com) 背景22年初从上家互联网公司离职以后,充分认识到互联网行业的风险,公司在没有自身稳定产品的情况下,互联网行业就是一个烧钱的行业,支出远远大于收入来源,上家公司就是如......
  • 成都.NET线下技术沙龙倒计时一天
    ​2023年4月15日下午13:30四川省成都市武侯区世纪城路198号世纪城新国际会展中心2区3楼.NET技术沙龙与你不见不散扫码即可报名活动......
  • ASP.NET Core MVC 从入门到精通之路由
    随着技术的发展,ASP.NETCoreMVC也推出了好长时间,经过不断的版本更新迭代,已经越来越完善,本系列文章主要讲解ASP.NETCoreMVC开发B/S系统过程中所涉及到的相关内容,适用于初学者,在校毕业生,或其他想从事ASP.NETCoreMVC系统开发的人员。 经过前几篇文章的讲解,初步了解ASP.NETCor......
  • codeforces #185 A Plant(矩阵快速幂+递推)
    题目地址:http://codeforces.com/problemset/problem/185/A通过这个题终于找回了点找递推公式的信心。。TAT。。不过真心感觉CF的题目质量都真不错。。。首先,第n个图形的上方,左下方,右下方的三个大三角形是跟第n-1个是一模一样的,所以是3*f(n-1)。然后只剩下中间一个倒着的大三角形了,......
  • HDU 2842 Chinese Rings(矩阵快速幂+递推)
    题目地址:HDU2842这个游戏是一个九连环的游戏。假设当前要卸下前n个环。由于要满足前n-2个都卸下,所以要先把前n-2个卸下,需要f(n-2)次。然后把第n个卸下需要1次,然后这时候要卸下第n-1个,然后此时前n-2个都已经被卸下了。这时候把前n-2个都卸下与都装上所需的次数是一样的,因为卸下与装......
  • #yyds干货盘点#【愚公系列】2023年04月 .NET CORE工具案例-.NET Core使用PaddleOCRSha
    (文章目录)前言PaddleOCRSharp是一个基于百度飞桨PaddleOCR的C++代码修改并封装的.NET的OCR工具类库。包含文本识别、文本检测、基于文本检测结果的统计分析的表格识别功能,同时针对小图识别不准的情况下,做了优化,提高识别准确率。包含总模型仅8.6M的超轻量级中文OCR,单模型支持中......
  • R语言对称矩阵提取上三角/下三角矩阵?
    目标输入矩阵col.1col.2col.3col.4row.11234row.25678row.39101112row.413141516输出矩阵col.1col.2col.3col.4row.11234row.2067......
  • 一次第三方访问不了系统且telnet端口不通的排查
    最近在测试环境与第三方安全厂商测试联调,对方反馈访问不了系统且telnet端口也不通,确认云服务器安全组和服务器防火墙均已正确配置放行策略,而且我放系统已运行一段时间,各办公网络通过访问正常,telnet也正常,初步判断应该不是我方系统问题,但是得证明不是我们这边问题,于是用tcpdump抓......
  • net外脑
    解压System.IO.Compression.ZipFileZipFile.OpenRead  读取压缩包ZipFile.OpenRead.Entries  读取压缩包里面所有的文件夹与文件1//获取地址2varUrl="Https://"+data["Url"]?.ToString();3//下载地址......
  • HDU 2604 Queuing(矩阵快速幂)
    题目地址:HDU2604这题只要推出公式来,构造矩阵就很容易了,问题是推不出公式来。。TAT。。从递推的思路考虑,用f(n)表示n个人满足条件的结果,如果最后一个是m则前n-1人可以任意排列,有f(n-1)种;如果是f,则考虑后两位mf和ff,没有一定满足或者一定不满足的状态,所以继续考虑一位,考虑后三位......