vb.net - 如何在 Dim NormalVectorRotationMatrix As New devDept.Geometry.Matrix 之后将元素添加到矩阵
问题描述
特别是DevDept.Geometry
在 VB.Net 应用程序中使用。我创建了一个新矩阵
现在我想用值填充矩阵?任何帮助,将不胜感激。
NormalVectorRotationMatrix
在 Visual Studio vb.net 中,创建从类命名的矩阵变量后,devDept.Geometry
我键入“ ” ,NormalVectorRotationMatrix.
它只显示 4 个方法[]Equals
,,,,[]GetHashcode
[]GetType
[]ToString
我希望看到一个属性/方法列表来定义矩阵的大小,然后看到一个元素列表来填充值。我错过了什么?
Dim NormalVectorRotationMatrix As New devDept.Geometry.Matrix
解决方案
如果你想创建一个视野矩阵,这很容易。使用时,您可以通过Transformation
类使用它,因此您可以直接跳过Matrix
对象并仅使用转换。
Matrix
您可能会对eyeshot 中的类不是对象这一事实感到困惑。它实际上是一个辅助类,并且矩阵本身一直只是双数组。
这是您可以使用的 2 种不同类型的矩阵及其工作原理的示例。
// create 2 transformations
var rotation = new devDept.Geometry.Rotation(radian, rotationVector);
var translate = new devDept.Geometry.Translation(x, y, z);
// just a simple object for demonstration purpose
Solid someSolid = Solid.CreateBox(10, 10, 10);
// rotate the solid
someSolid.TransformBy(rotation);
// or translate
someSolid.TransformBy(translate);
// or create a custom transformation (you see the point)
var transformation = rotation * translation * rotation
// apply that custom transformation
someSolid.TransformBy(transformation);
// or even better just create the matrix from scratch
var matrix4x4 = new double[16] {... define 4x4 matrix here ... };
// the transformation object takes a 4x4 double array matrix too
var matrixTransformation = new devDept.Geometry.Transformation(matrix4x4);
如果您使用过System.Media.Media3D.Matrix3D
or .net 然后将该对象正确转换为double[]
匹配Eyeshot
格式的对象,请使用以下静态方法
public static double[] ToEyeshotMatrix(this Matrix3D matrix)
{
// this is to format a windows matrix to the proper format eyeshot uses
return new[]
{
matrix.M11,matrix.M21,matrix.M31,matrix.OffsetX,
matrix.M12,matrix.M22,matrix.M32,matrix.OffsetY,
matrix.M13,matrix.M23,matrix.M33,matrix.OffsetZ,
matrix.M14,matrix.M24,matrix.M34,matrix.M44
};
}
// you can call it like so
var someMatrix = System.Media.Media3D.Matrix3D.Identity;
// apply normal .net transform you would do then
var eyeshotMatrix = new devDept.Geometry.Transformation(someMatrix.ToEyeshotMatrix());
这应该涵盖几乎所有可以在 eyeshot 和 .net 中使用矩阵的方式
作为您对特定矢量操作的评论的更新,您不需要目视。您在System.Windows.Media.Media3D
需要添加对PresentationCore
程序集的引用的命名空间中拥有它
你做这样的事情
// create some vector to change
var v = new System.Windows.Media.Media3D.Vector3D(1, 0, 0);
// create a matrix to transform our vector
var m = System.Windows.Media.Media3D.Matrix3D.Identity;
// rotate the matrix in Z 90 degree
m.Rotate(new System.Windows.Media.Media3D.Vector3D(0, 0, 1), 90d);
// apply the matrix to the vector
var resultVector = m.Transform(v);
// resultVector is now (0, 1, 0)
推荐阅读
- swift - 为什么子字符串的更改对从中减去的字符串没有影响?
- javascript - 如何做2个代码的组合?
- docker - 在 lxc proxmox 上安装和创建 Kubernetes 集群
- asp.net - 我无法在 vb.net 中设置引导类
- android - 如何在对话框中访问 EditText?
- database - 如何比较两个不同数据库中每个表的计数?
- mongodb - MongoDB合并数据库
- apache-storm - Storm 1.2.2 和 Kafka 版本 2.x
- python - 过采样类不平衡训练/测试拆分“发现样本数量不一致的输入变量”解决方案?
- playframework - 如何从 DatabaseConfigProvider 将进化应用到测试数据库