views:

253

answers:

2

I'm using .net WPF geometry classes to graph waveforms. I've been using the matrix transformations to convert from the screen coordinate space to my coordinate space for the waveform. Everything works great and it's really simple to keep track of my window and scaling, etc. I can even use the inverse transform to calculate the mouse position in terms of the coordinate space. I use the built in Scaling and Translation classes and then a custom matrix to do the y-axis flipping (there's not a prefab matrix for flipping). I want to be able to graph these waveforms on a log scale as well (either x axis or y axis or both), but I'm not sure if this is even possible to do with a matrix transformation. Does anyone know if this is possible, and if it is, what is the matrix?

+2  A: 

Matrices are linear transformations, so they can scale, rotate, etc. But they can't stretch logarithmically. That's a nonlinear transformation.

EDIT: But you should be able to roll this yourself, without undue trouble. (Doesn't require a knowledge of lin alg.) I mean, if you want the x axis to be on a logarithmic scale, take the log of the x coordinates that you're graphing. The tricky part is making the scale legend work on the side of the graph -- that boils down to transforming each scale value from x to 10^x (or whatever logarithm base you're using.)

So the legend would read:

1     10    100   1000

instead of

1      2      3      4
Rob Lachlan
Very much this.
Stephen Canon
thanks, yeah I kinda thought that might be the case, maybe there is a way to create my own implementation of the Transform class to do non-linear stuff? The Transform abstract base class still seems to use a matrix, and this is probably a necessity for doing the composite transformations, so maybe this isn't possible either. Guess I'm just going to have to do log scaling myself. Bummer.
Dave M
it's been way too long since I took linear algebra
Dave M
I'm not a WPF expert, but I looked over the description of the Transform class on MSDN, and it seems to be designed exclusively for linear transformations. (There's good reason for that -- they're very versatile, and much easier to reason about.)
Rob Lachlan
A: 

Well, clearly the matrix would be this:

( log(x) / x        0      ) ( x )  =  ( log(x) )
(      0        log(y) / y ) ( y )  =  ( log(y) )

But that's obviously not useful. You can't write a constant matrix to do a non-linear transformation.

Jefromi