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