Rotate the Square Around Paddle 1 - Demo 13¶
Objective¶
Rotate the square around paddle1’s center.

Demo 13¶
Move the Paddles using the Keyboard¶
Keyboard Input |
Action |
---|---|
w |
Move Left Paddle Up |
s |
Move Left Paddle Down |
k |
Move Right Paddle Down |
i |
Move Right Paddle Up |
d |
Increase Left Paddle’s Rotation |
a |
Decrease Left Paddle’s Rotation |
l |
Increase Right Paddle’s Rotation |
j |
Decrease Right Paddle’s Rotation |
UP |
Move the camera up, moving the objects down |
DOWN |
Move the camera down, moving the objects up |
LEFT |
Move the camera left, moving the objects right |
RIGHT |
Move the camera right, moving the objects left |
q |
Rotate the square around its center |
e |
Rotate the square around paddle 1’s center |
Description¶
Cayley Graph¶

Demo 13¶
src/modelviewprojection/demo13.py¶
134rotation_around_paddle1: float = 0.0
Event Loop¶
src/modelviewprojection/demo13.py¶
184while not glfw.window_should_close(window):
...
src/modelviewprojection/demo13.py¶
229 GL.glColor3f(0.0, 0.0, 1.0)
230 GL.glBegin(GL.GL_QUADS)
231 for ms in square:
232 ms_to_ndc: mu2d.InvertibleFunction = mu2d.compose(
233 [
234 # camera space to NDC
235 mu2d.uniform_scale(1.0 / 10.0),
236 # world space to camera space
237 mu2d.inverse(mu2d.translate(camera.position_ws)),
238 # model space to world space
239 mu2d.compose(
240 [
241 mu2d.translate(paddle1.position),
242 mu2d.rotate(paddle1.rotation),
243 ]
244 ),
245 # square space to paddle 1 space
246 mu2d.compose(
247 [
248 mu2d.rotate(rotation_around_paddle1),
249 mu2d.translate(mu2d.Vector2D(x=2.0, y=0.0)),
250 mu2d.rotate(square_rotation),
251 ]
252 ),
253 ]
254 )
255 square_vector_ndc: mu2d.Vector2D = ms_to_ndc(ms)
256 GL.glVertex2f(square_vector_ndc.x, square_vector_ndc.y)
257 GL.glEnd()