C# 中 3D 数学的好库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/607254/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Good library for 3D math in C#?
提问by Anton
I'm writing a tool that is going to be used to process a bunch of 3D data, doing things like rotating objects, translating, scaling and all that good stuff. Does anyone know of a good library that already does some of this common 3D stuff?
我正在编写一个工具,将用于处理一堆 3D 数据,执行诸如旋转对象、平移、缩放和所有好东西之类的操作。有谁知道一个好的库已经做了一些常见的 3D 东西?
I'm not interested in visualizing the data at the moment, and am primarily interested in performing the operations.
我目前对可视化数据不感兴趣,主要对执行操作感兴趣。
Things I know I will need at this point:
我知道此时我需要的东西:
- 2D/3D/4D vectors
- (adding, subtracting, dot product, cross product, etc...)
- Rotation/Translation/Scaling using matrices
- Quaternions
- 2D/3D/4D 矢量
- (加、减、点积、叉积等...)
- 使用矩阵进行旋转/平移/缩放
- 四元数
I was able to locate the Sharp3Dlibrary, but it seems like it might do what I want but hasn't been updated in a long time. Has anyone used this before? Any other (better) suggestions?
我能够找到Sharp3D库,但它似乎可以做我想做的事,但很长时间没有更新。有没有人以前用过这个?还有其他(更好的)建议吗?
采纳答案by Julien Hoarau
Microsoft.Xna.Framework(ship this XNA) could do the work.
Microsoft.Xna.Framework(发布此 XNA)可以完成这项工作。
The XNA Framework Math library has multiple basic geometric types that can be used to manipulate objects in 2D or 3D space. The primitive objects in this library represent the data required to represent a geometric object or an operation on that object. Each geometric type has a number of mathematical operations that are supported for the type.
Vector
The XNA Framework provides the Vector2, Vector3 and Vector4 classes for representing and manipulating vectors. A vector is typically used to represent a direction and magnitude. However, in the XNA framework it might also be used to store a coordinate or some other data type with the same storage requirements.
Each vector class has methods for performing standard vector operations such as:
- Dot product
- Cross product
- Normalization
- Transformation
- Linear, Cubic, Catmull-Rom, or Hermite spline interpolation.
Matrices
The XNA Framework provides the Matrix class for transformation of geometry. The Matrix class uses a row major order to address matrices, which means that the row is specified before the column when describing an element of a two-dimensional matrix. The Matrix class provides methods for performing standard matrix operations such as calculating the determinate or inverse of a matrix, in addition to helper methods for creating scale, translation, and rotation matrices.
Quaternions
The XNA Framework provides the Quaternion structure to represent and calculate the efficient rotation about a vector around a specified angle.
XNA Framework Math 库有多种基本几何类型,可用于操作 2D 或 3D 空间中的对象。该库中的原始对象表示表示几何对象或对该对象的操作所需的数据。每种几何类型都有许多该类型支持的数学运算。
向量
XNA 框架提供了 Vector2、Vector3 和 Vector4 类来表示和操作向量。矢量通常用于表示方向和大小。但是,在 XNA 框架中,它也可能用于存储坐标或具有相同存储要求的某些其他数据类型。
每个向量类都有执行标准向量操作的方法,例如:
- 点积
- 交叉产品
- 正常化
- 转型
- 线性、三次、Catmull-Rom 或 Hermite 样条插值。
矩阵
XNA 框架提供了用于几何变换的 Matrix 类。Matrix 类使用行主序来寻址矩阵,这意味着在描述二维矩阵的元素时,在列之前指定行。除了用于创建缩放、平移和旋转矩阵的辅助方法之外,Matrix 类还提供了用于执行标准矩阵运算的方法,例如计算矩阵的行列式或逆矩阵。
四元数
XNA Framework 提供了 Quaternion 结构来表示和计算围绕指定角度的向量的有效旋转。
回答by Julien Hoarau
Try Scinet Linea at www.obacs.com. It is not a free library but compared to alternatives it is not very expensive ww
在www.obacs.com 上试用 Scinet Linea 。它不是一个免费的图书馆,但与替代品相比,它并不是很贵 ww
回答by Julien Hoarau
Scinet Linea is not available from www.obacs.com anymore. It now comes within Scinet Math which has a lot more capabilities. I purchased a copy for my research a month ago. I like it so far.
www.obacs.com 不再提供 Scinet Linea。它现在包含在具有更多功能的 Scinet Math 中。一个月前,我为我的研究购买了一份副本。我喜欢它,到目前为止。
回答by BCS
I've never used it before but I just grabbed Sharp3D and it seems to work well (aside from some issue about strong names that took a few minutes to work around). My impression is that it's not exactly light weight but far from being on the heavy side.
我以前从未使用过它,但我只是使用了 Sharp3D,它似乎运行良好(除了一些需要几分钟才能解决的强名称问题)。我的印象是它不是很轻,但远非沉重。
As to no recent updates, it's not like math is changing or anything...
至于最近没有更新,这不像数学正在改变或任何事情......