Mercurial > touhou
diff pytouhou/utils/matrix.pyx @ 417:efae61ad6efe
Remove the type of the self argument in extension types, as it clutters the code with useless information.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 22 Aug 2013 12:21:12 +0200 |
parents | 5fe6cd6ceb48 |
children | d8630c086926 |
line wrap: on
line diff
--- a/pytouhou/utils/matrix.pyx +++ b/pytouhou/utils/matrix.pyx @@ -17,14 +17,14 @@ from ctypes import c_float cdef class Matrix: - def __init__(Matrix self, data=None): + def __init__(self, data=None): self.data = data or [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] - def __mul__(Matrix self, Matrix other): + def __mul__(self, Matrix other): out = Matrix() d1 = self.data d2 = other.data @@ -35,25 +35,25 @@ cdef class Matrix: return out - def get_c_data(Matrix self): + def get_c_data(self): data = sum(self.data, []) return (c_float * 16)(*data) - cpdef flip(Matrix self): + cpdef flip(self): data = self.data a, b, c, d = data[0] data[0] = [-a, -b, -c, -d] - cpdef scale(Matrix self, x, y, z): + cpdef scale(self, x, y, z): d1 = self.data d1[0] = [a * x for a in d1[0]] d1[1] = [a * y for a in d1[1]] d1[2] = [a * z for a in d1[2]] - cpdef scale2d(Matrix self, x, y): + cpdef scale2d(self, x, y): data = self.data d1a, d1b, d1c, d1d = data[0] d2a, d2b, d2c, d2d = data[1] @@ -61,7 +61,7 @@ cdef class Matrix: data[1] = [d2a * y, d2b * y, d2c * y, d2d * y] - cpdef translate(Matrix self, x, y, z): + cpdef translate(self, x, y, z): data = self.data a, b, c = data[3][:3] a, b, c = a * x, b * y, c * z @@ -73,7 +73,7 @@ cdef class Matrix: data[2] = [d3a + c, d3b + c, d3c + c, d3d + c] - cpdef rotate_x(Matrix self, angle): + cpdef rotate_x(self, angle): d1 = self.data cos_a = cos(angle) sin_a = sin(angle) @@ -81,7 +81,7 @@ cdef class Matrix: [sin_a * d1[1][i] + cos_a * d1[2][i] for i in range(4)]) - cpdef rotate_y(Matrix self, angle): + cpdef rotate_y(self, angle): d1 = self.data cos_a = cos(angle) sin_a = sin(angle) @@ -89,7 +89,7 @@ cdef class Matrix: [- sin_a * d1[0][i] + cos_a * d1[2][i] for i in range(4)]) - cpdef rotate_z(Matrix self, angle): + cpdef rotate_z(self, angle): d1 = self.data cos_a = cos(angle) sin_a = sin(angle)