【问题标题】:Vector.Multiply ignores offset values of matrixVector.Multiply 忽略矩阵的偏移值
【发布时间】:2013-05-01 16:05:01
【问题描述】:

我对WPF转换类的理解是Matrixrepresents a 3x3 row-major matrix of 2D homogenised coordinates where the final column is always(0,0,1)。我知道这种设计的原因是为了便于将平移表示为矩阵乘法,就像旋转、缩放和倾斜变换一样,而不是单独作为向量,如果使用 2x2 矩阵,就必须如此。

因此,我的期望是当 multiplyingVector 由包含翻译的矩阵时,结果向量应该被翻译。使用 WPF 矩阵类时,我似乎没有发生这种情况,那么我做错了什么?

Matrix m = new Matrix();
m.Translate(12, 34);

Vector v = new Vector(100, 200);
Vector r = Vector.Multiply(v, m);

// Confirm that the matrix was translated correctly
Debug.WriteLine(m);

// Confirm that the vector has been translated
Debug.WriteLine(r);

结果:

1,0,0,1,12,34    // Matrix contains translation as expected
100,200          // Vector is unchanged - not expected

【问题讨论】:

    标签: c# wpf linear-algebra matrix-multiplication homogenous-transformation


    【解决方案1】:

    我现在明白了。 VectorPoint 之间的区别很重要。我应该改用 Points 和 Point.Multiply,然后结果就是我所期望的。向量是两点之间的差异,不受平移影响,而点是受影响的特定位置。

    【讨论】:

    • 是的,但是回答你自己的问题是否符合规定?
    • 是的,推荐。它可以节省其他人的时间,并帮助其他面临同样问题的人。
    猜你喜欢
    • 1970-01-01
    • 2011-09-24
    • 2012-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-20
    相关资源
    最近更新 更多