如何在 WPF c# 中使用 MeshGeometry3D 绘制圆弧?

How can I draw an Arc using MeshGeometry3D in WPF c#?

我想在 Vieport3D 中使用 MeshGeometry3D.I 绘制 Arc 已经搜索了很多但没有找到任何东西,我找到的是使用 PathGeometry.I 我是 WPF 的新手所以不太了解3D graphics.How 我可以这样做吗?

感谢

这是我为 Arc.I 创建 mesh-geometry 所写的代码,希望这会对某人有所帮助。

 private GeometryModel3D GetModel(double radius, Vector3D normal, Point3D center, int resolution, double StartAngle, double EndAngle)
    {
        var mod = new GeometryModel3D();
        var geo = new MeshGeometry3D();

        // Generate the circle in the XZ-plane
        // Add the center first
        geo.Positions.Add(new Point3D(0, 0, 0));

        // Iterate from angle 0 to 2*PI
        double dev = (2 * Math.PI) / resolution;
        double thik = 0.02;
        //float spaceangle = StartAngle + 1;
        if (StartAngle != EndAngle)
        {
            for (double i = StartAngle; i < EndAngle; i += dev)
            {
                geo.Positions.Add(new Point3D(radius * Math.Cos(i), 0, -radius * Math.Sin(i)));
                geo.Positions.Add(new Point3D((radius-thik) * Math.Cos(i), 0, (-(radius-thik)) * Math.Sin(i)));
            }


            for (int i = 3; i < geo.Positions.Count; i += 1)
            {
                geo.TriangleIndices.Add(i - 3);
                geo.TriangleIndices.Add(i - 1);
                geo.TriangleIndices.Add(i - 2);

                geo.TriangleIndices.Add(i - 1);
                geo.TriangleIndices.Add(i);
                geo.TriangleIndices.Add(i - 2);
            }
        }


        mod.Geometry = geo;
        // Create transforms
        var trn = new Transform3DGroup();
        // Up Vector (normal for XZ-plane)
        var up = new Vector3D(0, 1, 0);
        // Set normal length to 1
        normal.Normalize();
        var axis = Vector3D.CrossProduct(up, normal); // Cross product is rotation axis
        var angle = Vector3D.AngleBetween(up, normal); // Angle to rotate
        trn.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(axis, angle)));
        trn.Children.Add(new TranslateTransform3D(new Vector3D(center.X, center.Y, center.Z)));

        mod.Transform = trn;
        return mod;


    }