【发布时间】:2013-05-01 16:05:01
【问题描述】:
我对WPF转换类的理解是Matrix类represents a 3x3 row-major matrix of 2D homogenised coordinates where the final column is always(0,0,1)。我知道这种设计的原因是为了便于将平移表示为矩阵乘法,就像旋转、缩放和倾斜变换一样,而不是单独作为向量,如果使用 2x2 矩阵,就必须如此。
因此,我的期望是当 multiplying 和 Vector 由包含翻译的矩阵时,结果向量应该被翻译。使用 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