【问题标题】:Is there Point3D?有Point3D吗?
【发布时间】:2013-03-29 11:36:37
【问题描述】:

.Net 中是否有内置类型 Point3? 有点这样的

public class Point3D
{
    public double X { get; set; }
    public double Y { get; set; }
    public double Z { get; set; }
}

但是内置的。自己实现也不难,但是..

【问题讨论】:

标签: c# .net point


【解决方案1】:

System.Windows.Forms.DataVisualization.ChartingPoint3D 类。

表示三维 (3D) 数据点的坐标。使用 3D 图表执行自定义绘图时使用此类。

  • X     获取或设置 3D 点的 X 坐标。
  • Y     获取或设置 3D 点的 Y 坐标。
  • Z     获取或设置 3D 点的 Z 坐标。

还有Point3D 结构。

表示 3-D 空间中的 x、y 和 z 坐标点。

【讨论】:

  • 确实如此。但是,如果您的代码还没有使用这些库之一,那么为这样一个简单的数据存储类添加对它们的依赖将是愚蠢的。自己定义就好。
  • 我意识到我参加这个聚会迟到了,但你自己的课程的另一个优点是你可以让它在必要时处理单位转换。
  • @TerryTyson - 或者使用内置类,并定义扩展方法。
【解决方案2】:

System.Windows.Forms.DataVisualization.Charting 有一个class Point3D

  • float X, Y, Z
  • System.Windows.Forms.DataVisualization.dll (WinForms)
  • .NET 框架 >= 4.0

System.Windows.Media.Media3D 有一个struct Point3D

  • double X, Y, Z
  • PresentationCore.dll (WPF)
  • .NET 框架 >= 3.0
  • .NET Core >= 3.0

我知道 Vector3D 不是 Point3D,但如果你只想要一个带有 X、Y、Z 的 struct

System.Windows.Media.Media3D 有一个struct Vector3D

  • double X, Y, Z
  • PresentationCore.dll (WPF)
  • .NET 框架 >= 3.0
  • .NET Core >= 3.0

System.Numerics 有一个struct Vector3

  • float X, Y, Z
  • System.Numerics.dll
  • .NET 框架 >= 4.6
  • .NET Core >= 1.0

System.Numerics.Vector3 不依赖 WinForms 或 WPF!

【讨论】:

    【解决方案3】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-17
      • 1970-01-01
      • 2013-09-02
      • 2012-02-21
      • 2021-06-09
      相关资源
      最近更新 更多