Skip navigation

You know what makes me mad? System.Windows.Media.Matrix.Transform( System.Windows.Vector ) ACTUALLY IGNORES the translation component.

To get System.Windows.Media.Matrix.Transform to take into account the translation component, you have to pass it a System.Windows.Point, and NOT a System.Windows.Vector.

I want to use System.Windows.Vector for the operator overloading. So this is really inconvenient. After every transformation I have to remember to write

// vecs is an array of Vector[]
matTransform.Transform( vecs ) ;

// Microsoft dumbness:  Matrix.Transform( Vector ) does not apply
// the translation component, so we have to apply it ourselves
for( int i = 0 ; i < vecs.Length ; i ++ )
  vecs[ i ].X += matTransform.OffsetX ;
  vecs[ i ].Y += matTransform.OffsetY ;

This seems so dumb and unintuitive to me. Yes, a “vector” is being distinguished from a “point” by the idea that a vector is just a magnitude and direction without having an absolute position in space, while a “point” describes a point in space, but PRACTICALLY, this isn’t how I’d think to use it. The System.Drawing.Matrix was a lot smarter, with a System.Drawing.Matrix.TransformPoints method (correctly applies translation) AND a System.Drawing.Matrix.TransformVectors method, in case you want stupid unintuitive behavior of ignoring the translation component.

Its not even documented that this is how System.Windows.Media.Matrix behaves (they must be too embarrassed to admit it, no), you have to infer it from the old version of the documentation.

It makes me so mad because WHY WOULD I EVER want a matrix translation component not to be applied? Me, I’d simply zero out Matrix.OffsetX and Matrix.OffsetY before applying the transformation if I wanted that part to be ignored. I’m used to working in 3D where the transformation matrix is simply applied to the vectors, OBVIOUSLY applying the translation component. It just doesn’t make intuitive sense to me to have VECTORS ignore the translation component.

I see this as a HUGE defect in the library, ESPECIALLY since differing behavior is determined by OVERLOAD.. it just seems SO stupid and unintuitive. Another one for never put a sock in a toaster..

Overloads should DO THE EXACT SAME THING, only on different types of inputs. If you want functions that do different things, then do it right and write two separate functions.


One Trackback/Pingback

  1. […] operator overloading. Now you would go and do something stupid like, I don’t know, make it so the translation elements of this matrix (third row) are ignored for Matrix.Transform( Vector ) and N… No. That would be stupid and unintuitive, no? Well, that’s what Microsoft […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: