Vector.Multiply ignores offset values of matrix

My understanding of the WPF transformation classes is that the Matrix class represents a 3x3 row-major matrix of 2D homogenised coordinates where the final column is always (0,0,1). I understand that the reason for this design is to facilitate translations to be represented as matrix multiplications, in the same way as rotate, scale and skew transformations, rather than separately as vectors, which would have to be the case if 2x2 matrices were used.

My expectation therefore is that when multiplying a Vector by a Matrix that contains a translation, the resultant vector should be translated. This does not seem to be happening for me when using the WPF matrix classes, so what am I doing wrong?

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);

Results:

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

Answers


I see now. The distinction between a Vector and a Point is important. I should be using Points and Point.Multiply instead, and then the results are what I was expecting. A vector is the difference between two points, which is unaffected by a translation, whereas a point is a specific location which is affected.


Need Your Help

How to render a view when model is fetched from multiple urls

javascript jquery ajax backbone.js asynchronous

I am working in project with backbone.js and the problem I am facing is that I have a model that doesn't need to be in sync with the server, this model its only intended to fetch user data to init...

Efficient way to check all points around a given point

javascript optimization canvas points

Hey, I recently wrote this fairly simple game of life in JavaScript.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.