Mercurial > touhou
annotate pytouhou/utils/matrix.pyx @ 491:2276229282fd
Fix gcc’s warnings with -Wall -Wextra.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 04 Oct 2013 14:32:28 +0200 |
parents | 878273a984c4 |
children | 26c082870dcf |
rev | line source |
---|---|
52
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
1 # -*- encoding: utf-8 -*- |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
2 ## |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
3 ## Copyright (C) 2011 Thibaut Girka <thib@sitedethib.com> |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
4 ## |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
5 ## This program is free software; you can redistribute it and/or modify |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
6 ## it under the terms of the GNU General Public License as published |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
7 ## by the Free Software Foundation; version 3 only. |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
8 ## |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
9 ## This program is distributed in the hope that it will be useful, |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
12 ## GNU General Public License for more details. |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
13 ## |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
44
diff
changeset
|
14 |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
123
diff
changeset
|
15 from libc.math cimport sin, cos |
423
d8630c086926
Replace Pyglet with our own Cython OpenGL wrapper.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
417
diff
changeset
|
16 from libc.stdlib cimport malloc, free |
d8630c086926
Replace Pyglet with our own Cython OpenGL wrapper.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
417
diff
changeset
|
17 |
d8630c086926
Replace Pyglet with our own Cython OpenGL wrapper.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
417
diff
changeset
|
18 |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
123
diff
changeset
|
19 cdef class Matrix: |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
20 def __init__(self, data=None): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
21 if data is None: |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
22 data = [1, 0, 0, 0, |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
23 0, 1, 0, 0, |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
24 0, 0, 1, 0, |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
25 0, 0, 0, 1] |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
26 for i in xrange(4): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
27 for j in xrange(4): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
28 self.data[i*4+j] = data[4*i+j] |
423
d8630c086926
Replace Pyglet with our own Cython OpenGL wrapper.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
417
diff
changeset
|
29 |
d8630c086926
Replace Pyglet with our own Cython OpenGL wrapper.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
417
diff
changeset
|
30 |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
31 def __mul__(Matrix self, Matrix other): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
32 cdef float *d1, *d2, *d3 |
370
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
131
diff
changeset
|
33 |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
131
diff
changeset
|
34 out = Matrix() |
411
2428296cccab
Remove indirect access to Matrix values.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
35 d1 = self.data |
2428296cccab
Remove indirect access to Matrix values.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
36 d2 = other.data |
2428296cccab
Remove indirect access to Matrix values.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
37 d3 = out.data |
370
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
131
diff
changeset
|
38 for i in xrange(4): |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
131
diff
changeset
|
39 for j in xrange(4): |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
40 d3[4*i+j] = 0 |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
41 for k in xrange(4): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
42 d3[4*i+j] += d1[4*i+k] * d2[4*k+j] |
370
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
131
diff
changeset
|
43 return out |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
131
diff
changeset
|
44 |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
131
diff
changeset
|
45 |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
46 cdef void flip(self) nogil: |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
47 cdef float *data |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
48 |
123 | 49 data = self.data |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
50 for i in xrange(4): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
51 data[i] = -data[i] |
28
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
52 |
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
53 |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
54 cdef void scale(self, float x, float y, float z) nogil: |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
55 cdef float *data, coordinate[3] |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
56 |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
57 data = self.data |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
58 coordinate[0] = x |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
59 coordinate[1] = y |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
60 coordinate[2] = z |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
61 |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
62 for i in xrange(3): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
63 for j in xrange(4): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
64 data[4*i+j] *= coordinate[i] |
28
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
65 |
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
66 |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
67 cdef void scale2d(self, float x, float y) nogil: |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
68 cdef float *data |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
69 |
123 | 70 data = self.data |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
71 for i in xrange(4): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
72 data[ i] *= x |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
73 data[4+i] *= y |
31 | 74 |
75 | |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
76 cdef void translate(self, float x, float y, float z) nogil: |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
77 cdef float *data, coordinate[3], item[3] |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
78 |
123 | 79 data = self.data |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
80 coordinate[0] = x |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
81 coordinate[1] = y |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
82 coordinate[2] = z |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
83 for i in xrange(3): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
84 item[i] = data[12+i] * coordinate[i] |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
85 |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
86 for i in xrange(3): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
87 for j in xrange(4): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
88 data[4*i+j] += item[i] |
28
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
89 |
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
90 |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
91 cdef void rotate_x(self, float angle) nogil: |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
92 cdef float cos_a, sin_a |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
93 cdef float lines[8], *data |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
94 |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
95 data = self.data |
28
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
96 cos_a = cos(angle) |
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
97 sin_a = sin(angle) |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
98 for i in xrange(8): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
99 lines[i] = data[i+4] |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
100 for i in xrange(4): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
101 data[4+i] = cos_a * lines[i] - sin_a * lines[4+i] |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
102 data[8+i] = sin_a * lines[i] + cos_a * lines[4+i] |
28
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
103 |
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
104 |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
105 cdef void rotate_y(self, float angle) nogil: |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
106 cdef float cos_a, sin_a |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
107 cdef float lines[8], *data |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
108 |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
109 data = self.data |
28
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
110 cos_a = cos(angle) |
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
111 sin_a = sin(angle) |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
112 for i in xrange(4): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
113 lines[i] = data[i] |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
114 lines[i+4] = data[i+8] |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
115 for i in xrange(4): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
116 data[ i] = cos_a * lines[i] + sin_a * lines[4+i] |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
117 data[8+i] = -sin_a * lines[i] + cos_a * lines[4+i] |
28
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
118 |
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
119 |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
120 cdef void rotate_z(self, float angle) nogil: |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
121 cdef float cos_a, sin_a |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
122 cdef float lines[8], *data |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
123 |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
124 data = self.data |
28
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
125 cos_a = cos(angle) |
f405b947624d
Massive sprite updating/matrix handling optimizations
Thibaut Girka <thib@sitedethib.com>
parents:
4
diff
changeset
|
126 sin_a = sin(angle) |
435
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
127 for i in xrange(8): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
128 lines[i] = data[i] |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
129 for i in xrange(4): |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
130 data[ i] = cos_a * lines[i] - sin_a * lines[4+i] |
878273a984c4
Improve Matrix representation, using float[16] instead of imbricated python lists.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
424
diff
changeset
|
131 data[4+i] = sin_a * lines[i] + cos_a * lines[4+i] |