# [Matrix-SIG] matrix transformations on vector graphics

**Just van Rossum
**
just@letterror.com

*Wed, 15 Apr 1998 19:38:32 +0200*

Hello,
I am very new to NumPy, and I would like some tips on how to efficiently do
transformations for vector graphics (I mean, NumPy just screams "use me!"
to me for this kind of stuff ;-).
Say, I have an array of 2D coordinates:
v = Numeric.array([(0.0, 0.0), (10.0, 0.0), (100.0, 75.0), etc...])
and a simple transformation matrix (this one should flip the y coordinate):
tm = Numeric.array([[1.0, 0, 0], [0, -1.0, 0], [0, 0, 1.0]])
Is there a convenient way to apply the matrix to the vector array?
If I turn the x and y values into separate arrays, I could probably do
something like this:
[x, y] = Numeric.transpose(v)
xnew = tm[0][0] * x + tm[0][1] * y + tm[2][0]
ynew = tm[1][0] * x + tm[1][1] * y + tm[2][1]
But if I in general would prefer xy pairs, I would have to do
Numeric.transpose() before and after I do this. Or is transpose()
relatively cheap? Did I just answer my own question?
What more introduction material is there besides David Ascher's wonderful
pages and the stuff that comes with NumPy?
Thanks in advance for any pointers or tips.
Just