7 examples of 'rotate matrix python' in Python

Every line of 'rotate matrix python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
248def Rotate(self, dir):
249 self.RemoveShape(self.curshape.y, self.curshape.x, self.curshape.shape,
250 self.curshape.rotation);
251 newrot = dir + self.curshape.rotation;
252
253 if(newrot<0):
254 newrot = shapes[self.curshape.shape].rot - 1;
255 if(newrot==shapes[self.curshape.shape].rot):
256 newrot = 0;
257 ret=self.CheckMove(0, 0, self.curshape.shape, newrot);
258
259 if(ret):
260 self.curshape.rotation = newrot;
261
262 self.PutShape(self.curshape.y, self.curshape.x, self.curshape.shape,
263 self.curshape.rotation);
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

108def rotate(x, y, angle):
109 """rotation transformation for a point."""
110 cost = cos(angle) #cost is short for cos(theta)
111 sint = sin(angle)
112 newx = x * cost - y * sint
113 newy = x * sint + y * cost
114 return (newx, newy)
135def rotate(self, degrees, clockwise=False):
136 """
137 Returns an AffineTransform which is rotated by the given number
138 of degrees. Anticlockwise unless clockwise=True is given.
139 """
140 degrees %= 360
141 if clockwise:
142 degrees = 360 - degrees
143 theta = degrees * pi / 180.0
144
145 # HACK: limited precision of floats means rotate() operations
146 # often cause numbers like 1.2246467991473532e-16.
147 # So we round() those to 15 decimal digits. Better solution welcome :/
148 rotation = AffineTransform((
149 round(cos(theta), 15), round(-sin(theta), 15), 0,
150 round(sin(theta), 15), round(cos(theta), 15), 0,
151 0, 0, 1,
152 ))
153 return self * rotation
139def _rotate(self, angle):
140 '''Change the current rotation'''
141 r = self.current_rotation + angle
142
143 if r == 360:
144 r = 0
145 if r < 0:
146 r += 360
147 elif r > 360:
148 r -= 360
149
150 self.current_rotation = r
200@classmethod
201def y_rotation(cls, angle):
202 """Creates a Matrix44 that does a rotation about the y axis.
203
204 angle -- Angle of rotation (in radians)
205
206 """
207
208 m = cls.__new__(cls, object)
209 return m.make_y_rotation(angle)
11def rot_mtx(angle):
12 cs = np.cos(angle)
13 sn = np.sin(angle)
14 return np.array([[cs, 0., sn, 0., 0., 0.],
15 [0., cs, 0., sn, 0., 0.],
16 [-sn, 0., cs, 0., 0., 0.],
17 [0., -sn, 0., cs, 0., 0.],
18 [0., 0., 0., 0., 1., 0.],
19 [0., 0., 0., 0., 0., 1.]])
24def rotate(x, y, c, s):
25 tx = x * c - y * s;
26 y = x * s + y * c;
27 x = tx;
28 return [x,y]

Related snippets