[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Passing pionts through a matrix.

campbell barton wrote:

Hi, I am thinking about making a program where you can pass a list of points (x,y) through a rotation/scale/distortion matrix.
This could be done through python but I was wondering if numeric would be better?

It would be a polyline - Not a image.
- Cam

In numeric is another module called Matrix.

import Matrix

They are pretty much the same as opengl matrices. Below is how to make a translation matrix. Just make your points z be 0.

def create_translation_matrix(position):
""" returns a translation matrix from the position given(x,y,z).
x,y,z = position
return Matrix.Matrix( [[ 1., 0., 0., 0.,],
[ 0., 1., 0., 0.,],
[ 0., 0., 1., 0.,],
[ x, y, z, 1.,] ] )

Have fun!