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¶
163rotation_around_paddle1: float = 0.0
Event Loop¶
src/modelviewprojection/demo13.py¶
213while not glfw.window_should_close(window):
...
src/modelviewprojection/demo13.py¶
251 glColor3f(0.0, 0.0, 1.0)
252 glBegin(GL_QUADS)
253 for ms in square:
254 ms_to_ndc: InvertibleFunction[Vector2D] = compose(
255 # camera space to NDC
256 uniform_scale(1.0 / 10.0),
257 # world space to camera space
258 inverse(translate(camera.position_ws)),
259 # model space to world space
260 compose(translate(paddle1.position), rotate(paddle1.rotation)),
261 # square space to paddle 1 space
262 compose(
263 rotate(rotation_around_paddle1),
264 translate(Vector2D(x=2.0, y=0.0)),
265 rotate(square_rotation),
266 ),
267 )
268 square_vector_ndc: Vector2D = ms_to_ndc(ms)
269 glVertex2f(square_vector_ndc.x, square_vector_ndc.y)
270 glEnd()