当前位置: 首页> 健康> 科研 > 网站在线制作软件_手机网站建设费用价格_腾讯网网站网址_西安seo关键词排名

网站在线制作软件_手机网站建设费用价格_腾讯网网站网址_西安seo关键词排名

时间:2025/7/11 19:48:38来源:https://blog.csdn.net/yongshiqq/article/details/146515523 浏览次数:0次
网站在线制作软件_手机网站建设费用价格_腾讯网网站网址_西安seo关键词排名

 

using Autodesk.AutoCAD.Geometry; // 使用 AutoCAD 的几何库

public static class CoordinateProjection
{
    /// <summary>
    /// 在 AutoCAD 中实现 XY→XZ 平面坐标转换
    /// </summary>
    public static Point3d ProjectBetweenStandardPlanes(Point3d point, string fromPlane, string toPlane)
    {
        switch (fromPlane.ToUpper() + "_" + toPlane.ToUpper())
        {
            case "XY_XZ": return new Point3d(point.X, point.Z, point.Y); // (1,1,0) → (1,0,1)
            case "XY_YZ": return new Point3d(point.Z, point.Y, -point.X);
            case "XZ_XY": return new Point3d(point.X, point.Z, point.Y);
            case "XZ_YZ": return new Point3d(point.Z, point.X, point.Y);
            case "YZ_XY": return new Point3d(-point.Z, point.Y, point.X);
            case "YZ_XZ": return new Point3d(point.Y, point.X, point.Z);
            default: return point;
        }
    }
}

Point3d pointInXY = new Point3d(1, 1, 0);
Point3d pointInXZ = CoordinateProjection.ProjectBetweenStandardPlanes(pointInXY, "XY", "XZ");
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage($"转换结果: {pointInXZ}\n"); // 输出 (1, 0, 1)

 

public static Point3d TransformPoint(Point3d point, Vector3d newX, Vector3d newY, Vector3d newZ, Point3d origin)
{
    // 构建变换矩阵
    Matrix3d mat = Matrix3d.AlignCoordinateSystem(
        Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, // 原坐标系
        origin, newX, newY, newZ // 新坐标系
    );
    return point.TransformBy(mat);
}

// 示例:XY → XZ 转换
Point3d pointInXY = new Point3d(1, 1, 0);
Point3d pointInXZ = TransformPoint(
    pointInXY,
    Vector3d.XAxis,  // 新 X 轴 = 原 X 轴
    Vector3d.ZAxis,  // 新 Y 轴 = 原 Z 轴
    -Vector3d.YAxis, // 新 Z 轴 = -原 Y 轴
    Point3d.Origin
);
// 结果: (1, 0, 1)

 

 

 

 

 

## **方案 2:在非 Revit 环境(如控制台应用)**

如果 **没有 Revit**,可以用 `System.Numerics.Vector3`(需要安装 NuGet 包):

### **步骤 1:安装 NuGet 包**

```bash

Install-Package System.Numerics

XYZ pointInXY = new XYZ(1, 1, 0);
XYZ pointInXZ = CoordinateProjection.ProjectBetweenStandardPlanes(pointInXY, "XY", "XZ");
// 结果将是 (1, 0, 1)

 

public static XYZ ProjectBetweenStandardPlanes(XYZ point, string fromPlane, string toPlane)

 

{
// 设置默认基向量
XYZ fromX = XYZ.BasisX, fromY = XYZ.BasisY, fromZ = XYZ.BasisZ;
XYZ toX = XYZ.BasisX, toY = XYZ.BasisY, toZ = XYZ.BasisZ;
switch (fromPlane.ToUpper() + "_" + toPlane.ToUpper())
{
case "XY_XZ":
// XY → XZ: (x,y,z) → (x,z,y)
return new XYZ(point.X, point.Z, point.Y);
case "XY_YZ":
// XY → YZ: (x,y,z) → (z,y,-x)
return new XYZ(point.Z, point.Y, -point.X);
case "XZ_XY":
// XZ → XY: (x,y,z) → (x,z,y)
return new XYZ(point.X, point.Z, point.Y);
case "XZ_YZ":
// XZ → YZ: (x,y,z) → (z,x,y)
return new XYZ(point.Z, point.X, point.Y);
case "YZ_XY":
// YZ → XY: (x,y,z) → (-z,y,x)
return new XYZ(-point.Z, point.Y, point.X);
case "YZ_XZ":
// YZ → XZ: (x,y,z) → (y,x,z)
return new XYZ(point.Y, point.X, point.Z);
default:
return point; // 相同平面不转换
}
}
关键字:网站在线制作软件_手机网站建设费用价格_腾讯网网站网址_西安seo关键词排名

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: